home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / netlangc.arc / NETLANG.C
Encoding:
C/C++ Source or Header  |  1985-09-05  |  159.4 KB  |  4,187 lines

  1. Article 4303 (653 more) in net.lang.c:
  2. From: teach0@whuts.UUCP (CTD_STUDENT0.)
  3. Subject: Re: Structure question (problem)
  4. Message-ID: <123@whuts.UUCP>
  5. Date: 23 May 85 12:59:40 GMT
  6. Date-Received: 26 May 85 07:14:55 GMT
  7. References: <185@vger.UUCP>
  8. Organization: AT&T Bell Laboratories
  9. Lines: 44
  10.  
  11. --MORE--(34%)> Could someone please inform me what the hell I am doing wrong.  The
  12. > subject is auto-initialization of structures.  Here is a simple program
  13. > that trys to initialize the stucture, and the associated error
  14. > message.  If I take one of K&R's examples (pg 124, last half page),
  15. > I get the same error.
  16. > BTW-This is 4.2bsd.
  17. > =====
  18. > /* Structure test */
  19. > #include <stdio.h>
  20. > main() {
  21. >       static char *text[] = { "Fred", "Wilma", "Barney", "Betty" };
  22. >       struct l {
  23. >               int a;
  24. >               int b;
  25. >               char *c;
  26. >               int d; 
  27. >                } e = { 0, 1, text[0], 4 };
  28. >       
  29. >       printf("Fred is married to Wilma, Barney to Betty...\n");
  30. > }
  31. > =====
  32. > % cc t.c
  33. > "t.c", line 14: no automatic aggregate initialization
  34. > "t.c", line 14: warning: illegal combination of pointer and integer, op =
  35. Aggregates (arrays, structures, unions) can only be initialized if
  36. they are declared static or external. A simple:
  37.  
  38.         static struct l{ .........
  39.  
  40. will do.
  41.  
  42. --
  43.  
  44. Fred Eng
  45. AT&T Bell Laboratories
  46. (Mail) End of article 4303 (of 4956)--what next? [npq] 
  47.  
  48. Article 4436 (520 more) in net.lang.c:
  49. From: chongo@nsc.UUCP (Landon Noll)
  50. Subject: Re: 2nd Annual Obfuscated Contest Winners
  51. Message-ID: <2919@nsc.UUCP>
  52. Date: 29 Jun 85 04:53:13 GMT
  53. Date-Received: 4 Jul 85 05:49:40 GMT
  54. References: <2902@nsc.UUCP> <36@bbnccv.UUCP>
  55. Reply-To: chongo@nsc.UUCP (Landon Noll)
  56. Distribution: net
  57. Organization: Rational Swamiconductor, Sanivale
  58. Lines: 29
  59. Keywords: precedence
  60. Summary: 
  61.  
  62. --MORE--(31%)In article <36@bbnccv.UUCP> keesan@bbnccv.UUCP (Morris M. Keesan) writes:
  63.  >1. The most obscure program:
  64.  >(submitted by Lennart Augustsson <seismo!mcvax!enea!chalmers!augustss> )
  65.  >
  66.  >is not legal C, even though the 4.2BSD compiler (and presumably other PCC-based
  67.  >compilers) processes it as the author apparently intended.
  68.  >
  69.  >For these two reasons, especially the first, I don't think this program
  70.  >deserves a prize.  Also, this is a bug in the 4.2BSD compiler, and even more
  71.  >so in the 4.2BSD lint, which should issue a warning even if the compiler is
  72.  >being forgiving.
  73.  
  74. So it breaks on other compilers eh?  Well such is life with a Obfuscated C
  75. contest!  One has to hand it to someone for finding a "hole" in a compiler,
  76. and driving a truck through it. 
  77.  
  78. The contest rules stated that it has to be in "Common C".  There was nothing
  79. to point out that it HAD to be standard C, K&R C, or Deathstar Unix C.
  80. The ability to run an entry on other systems was a plus, not a rule.  Also,
  81. we did not try, nor did we intend to check out each program on every
  82. system/compiler.  We did not have time, or resources to do so!
  83.  
  84. Thank you for posting a suggested change so that other people might see
  85. what the program does.   If anyone else finds another porting problem,
  86. you might consider posting a bug fix to net.sources.bugs.
  87.  
  88. chongo <in any event, the awards are final> /\../\
  89. -- 
  90. no comment is a comment.
  91. (Mail) End of article 4436 (of 4956)--what next? [npq] 
  92.  
  93. Article 4718 (238 more) in net.lang.c:
  94. From: cdshaw@watmum.UUCP (Chris Shaw)
  95. Subject: Re: "writing code"
  96. Message-ID: <227@watmum.UUCP>
  97. Date: 26 Jul 85 07:23:08 GMT
  98. Date-Received: 3 Aug 85 17:22:00 GMT
  99. References: <418@spar.UUCP> <408@utastro.UUCP>
  100. Reply-To: cdshaw@watmum.UUCP (Chris Shaw)
  101. Organization: U of Waterloo, Ontario
  102. Lines: 36
  103.  
  104. --MORE--(28%)>General question: does anybody "write code" on paper first any more?
  105. >-- 
  106. >Ed Nather
  107.  
  108.  
  109. For me, there is a choice: write it twice (on paper then on screen),
  110. or write it once (on screen only).
  111.  
  112. However, it isn't as hard-and-fast as that. This only truly works for 
  113. simple stuff. For hard programs, I use paper for "getting the algorithm 
  114. into my head". Recently, for example, I had to do a complicated data structure
  115. conversion. The result was terrifically simple, but the core of the
  116. thing was a...
  117.                 x[ --b[ x[ --b[i] ] ] ] = i ;
  118.  
  119. ..kind of affair, which required a lot of thought, and had to be designed
  120. with pictures of linked data structures, etc. etc.
  121.  
  122. The point of all this is that the tools called "paper & pencil" are 
  123. inadequate for designing programs at the textual level, because line 
  124. insertion is improbable, and looks like hell if you do more than a little.
  125.  
  126. Drawing pictures with pencil is easy, though, and impossible on your
  127. normal terminal. If I had access to a good graphics package, one with real
  128. flexibility & "definable actions", then I'd drop paper altogether for design.
  129.  
  130. The conclusion is that this is really an ergonomics issue (if I take the
  131. meaning correctly). Tools that are completely satisfactory/comfortable 
  132. will displace those that aren't.
  133.  
  134.  
  135. Chris Shaw    watmath!watmum!cdshaw  or  cdshaw@watmath
  136. University of Waterloo
  137.  
  138. Work is the curse of the drinking classes.
  139.                 - Oscar Wilde
  140. (Mail) End of article 4718 (of 4956)--what next? [npq] 
  141.  
  142. Article 4719 (237 more) in net.lang.c:
  143. From: guy@sun.uucp (Guy Harris)
  144. Subject: Re: c programming style - READ THIS
  145. Message-ID: <2491@sun.uucp>
  146. Date: 26 Jul 85 07:35:37 GMT
  147. Date-Received: 3 Aug 85 17:32:55 GMT
  148. References: <11570@brl-tgr.ARPA> <935@teddy.UUCP> <1286@uwmacc.UUCP> <2439@sun.uucp> <39@escher.UUCP>
  149. Organization: Sun Microsystems, Inc.
  150. Lines: 47
  151.  
  152. --MORE--(19%)> I use C largely because it DOES allow (encourage?) me to
  153. > think in terms of the underlying bit patterns involved.  I
  154. > pay very close attention to just what is happening to
  155. > pointers when they are changed; that is the price I pay for
  156. > fast running programs.
  157.  
  158. But is this a case of "thinking of the underlying bit patterns", or is it a
  159. case of thinking of the underlying operations on an abstract machine?  I.e.,
  160. do you think of a pointer as a natural number indexing a large array which
  161. is your process' address space (which may not work on a segmented machine!),
  162. or do you think of it as something that points to an object?  You can still
  163. think in the latter terms without forgetting the important part of how
  164. pointers are implemented - i.e., I doubt the ability to cast pointers to
  165. some integral type and back again is needed, in general, for efficiency
  166.  
  167. > When I AM concerned with performance, I have to put in the
  168. > effort to track every pointer on my own, and all the other
  169. > neat stuff C lets me do without PASCAL or ForTran style
  170. > run-time checking.
  171.  
  172. What do you mean by "track every pointer on (your) own"?  True, you can't
  173. use pointers in FORTRAN without run-time checking, but then you can't use
  174. pointers in FORTRAN *with* run-time checking, since it doesn't *have*
  175. pointers.  FORTRAN doesn't do much "run-time checking" because it doesn't
  176. have much checking to do - no pointers, so no null-pointer checking; no
  177. subrange or enumerated types, so no checking assignments to such types.  I
  178. believe there are many PASCAL compilers that will allow you to turn the
  179. checking off - of course, if you do so, you should have good reason to be
  180. sure the errors that the checking would detect should occur, considering
  181. that those errors can bomb your program regardless of whether it was written
  182. in PASCAL or C.  (For instance, if you get a pointer from a routine which
  183. could return a null pointer, *always* check it before using it unless you
  184. *know* that the particular call to that routine which returns the pointer
  185. won't return a null pointer.  And make *sure* you really "know" it.  Just
  186. because you created a file "/tmp/foo" and made it readable doesn't mean
  187. 'fopen("/tmp/foo", "r")' is not going to return NULL - you could get an I/O
  188. error, or somebody else could have unlinked the file while you weren't
  189. looking, or...)
  190.  
  191.  
  192. You don't have to think of pointers as integers indexing a large array which
  193. is your address space (and think of null pointers as being the integer 0) in
  194. order to write efficient C code.  (And if you do think that way, what you
  195. may end up with is C code that will break when somebody else tries to run it
  196. on their machine - which will force *them* to fix the problem.)
  197.  
  198.         Guy Harris
  199. (Mail) End of article 4719 (of 4956)--what next? [npq] 
  200.  
  201. Article 4720 (236 more) in net.lang.c:
  202. From: agt@pucc-k (Kevin Braunsdorf)
  203. Subject: Inconsistency in Style -> Unreadable Code
  204. Message-ID: <1207@pucc-k>
  205. Date: 26 Jul 85 21:26:56 GMT
  206. Date-Received: 3 Aug 85 17:34:10 GMT
  207. References: work at PUCC
  208. Organization: Solon Aquilla's Magic & Art Gallery
  209. Lines: 35
  210.  
  211. --MORE--(42%)
  212.     All: I am a Computing Center Consultant at Purdue so I see more
  213. different styles of coding per week than most programmers do in a year:
  214. in my view the only bad style is an inconsistent one, eg:
  215.  
  216.         kp = ++i * j;
  217.         j += 1;
  218.  
  219.         should be any of:
  220.         i++;                    i += 1;         kp = ++i * j++;
  221.         kp = i * j;             kp = i * j;
  222.         j++;                    j += 1;
  223.  
  224.         or even:
  225.         kp = (i += 1) * j;
  226.         j += 1;
  227.  
  228.     Anything that I can notice a set pattern to will help me read the code:
  229. as to the formatting of the code, I personally use
  230.         while (exp) {
  231.             ...
  232.         }       /* line close curly with while  */
  233.     but
  234.         while (exp) {
  235.             ...
  236.             }   /* indent curly too             */
  237.     works for me too, as long as
  238.         fnx()
  239.             {
  240.             ...
  241.             }
  242.     is used too!
  243.  
  244.                                                 :wq
  245.                                                 Kevin Braunsdorf
  246. (Mail) End of article 4720 (of 4956)--what next? [npq] 
  247.  
  248. Article 4721 (235 more) in net.lang.c:
  249. From: chuqui@nsc.UUCP (Chuq Von Rospach)
  250. Subject: Re: C Programming Style -- New thought  ("writing code")
  251. Message-ID: <3035@nsc.UUCP>
  252. Date: 27 Jul 85 04:07:36 GMT
  253. Date-Received: 4 Aug 85 00:57:45 GMT
  254. References: <418@spar.UUCP> <408@utastro.UUCP> <107@well.UUCP>
  255. Reply-To: chuqui@nsc.UUCP (Chuq Von Rospach)
  256. Organization: The Dreamer Fithp
  257. Lines: 13
  258. Summary: 
  259.  
  260. --MORE--(49%)In article <408@utastro.UUCP>, nather@utastro.UUCP (Ed Nather) writes:
  261. > General question: does anybody "write code" on paper first any more?
  262.  
  263. I use paper for any non-trivial design, and usually find myself going
  264. through three or four circuits fleshing it from something resembling
  265. pseudo-code to something resembling C. Even better, when I'm actually in my
  266. office, is my white board -- I don't know how people lived without them.
  267. -- 
  268. :From the carousel of the autumn carnival:        Chuq Von Rospach
  269. {cbosgd,fortune,hplabs,ihnp4,seismo}!nsc!chuqui   nsc!chuqui@decwrl.ARPA
  270.  
  271. Your fifteen minutes are up. Please step aside!
  272. (Mail) End of article 4721 (of 4956)--what next? [npq] 
  273.  
  274. Article 4723 (233 more) in net.lang.c:
  275. From: mauney@ncsu.UUCP (Jon Mauney)
  276. Subject: Re: Style, readability, etc. (use of comments)
  277. Message-ID: <2904@ncsu.UUCP>
  278. Date: 26 Jul 85 15:11:17 GMT
  279. Date-Received: 4 Aug 85 01:13:50 GMT
  280. References: <95@brl-tgr.ARPA>, <1207@sjuvax.UUCP>
  281. Organization: N.C. State University, Raleigh
  282. Lines: 39
  283.  
  284. --MORE--(22%)> From: jss@sjuvax.UUCP (J. Shapiro)
  285. > Subject: Re: Style, readability, etc. (long, but IMPORTANT)
  286. > Message-ID: <1207@sjuvax.UUCP>
  287. >   
  288. > > while(ptr++->duck)  /* move pointer to the duck after the next NULL */
  289. > >   ;
  290. > This one is even more obscure than the last.  I am a C programmer, and
  291. > this tells me nothing - indeed it is dead wrong, as it simply will not
  292. > happen as the comment might lead me to believe.  This will leave me
  293. > with ptr pointing to the next available record whose element named
  294. > duck is 0.  It certainly has nothing to do with NULL or anything after
  295. > duck.  This is one of the major difficulties with such comments.
  296. > There is a tendency even among experienced programmers to read them
  297. > and believe them, and thereby not see an obvious difficulty.
  298. > Jonathan S. Shapiro
  299. > Haverford College
  300. > ..!sjuvax!jss
  301.  
  302. Let me first point out that I agree that block comments are generally
  303. more useful than end-of-line comments.  However, there are many places
  304. in which an end-of-line comment is very useful.  The present example
  305. is one, as proved by the fact that apparently experienced C programmers
  306. cannot agree on the effect of the loop.  Code that is so susceptible to
  307. error should be avoided or heavily commented.
  308.  
  309. I look at comments as recording the programmer's *intent*, whereas the
  310. code is (obviously) what he actually *did*.  Reading the comments tells
  311. me whether the bug is likely due to a poor design.  If the design
  312. seems sound, then I look for discrepancies between code and comments.
  313. Any such discrepancy is a clear indication of a problem, although the
  314. problem may be as simple as a slip of the mind.  Comments add redundancy
  315. to a program, and redundancy is A Good Thing, in moderation.
  316. -- 
  317.  
  318. Jon Mauney,    mcnc!ncsu!mauney       "The door's not shut on my genius, but...
  319. North Carolina State University        I just don't have the time."
  320. (Mail) End of article 4723 (of 4956)--what next? [npq] 
  321.  
  322. Article 4724 (232 more) in net.lang.c:
  323. From: chris@umcp-cs.UUCP (Chris Torek)
  324. Subject: Re:  C Programming Style -- New thought (\"writing code\")
  325. Message-ID: <1017@umcp-cs.UUCP>
  326. Date: 26 Jul 85 21:31:08 GMT
  327. Date-Received: 4 Aug 85 02:23:43 GMT
  328. References: <189@brl-tgr.ARPA>
  329. Organization: U of Maryland, Computer Science Dept., College Park, MD
  330. Lines: 18
  331.  
  332. --MORE--(47%)>Typing ability probably has a lot to do with [programming on paper]
  333. >to [sic].
  334.  
  335. Could be; I never write actual code on paper, and I type MUCH faster
  336. than I write (I type reasonably quickly and write excruciatingly
  337. slowly)....
  338.  
  339. However, I don't think that writing code on paper gains you much
  340. if anything.  The key to writing good code is to have a clear
  341. understanding of the algorithm(s) involved.
  342.  
  343. In some cases I need to do a complete rewrite after I've got
  344. something working, once I know what I did wrong the first time
  345. around....
  346. -- 
  347. In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
  348. UUCP:   seismo!umcp-cs!chris
  349. CSNet:  chris@umcp-cs           ARPA:   chris@maryland
  350. (Mail) End of article 4724 (of 4956)--what next? [npq] 
  351.  
  352. Article 4725 (231 more) in net.lang.c:
  353. From: ado@elsie.UUCP (Arthur David Olson)
  354. Newsgroups: net.unix,net.lang.c
  355. Subject: Re: Portablity using structures and malloc - Help
  356. Message-ID: <5181@elsie.UUCP>
  357. Date: 27 Jul 85 00:36:19 GMT
  358. Date-Received: 4 Aug 85 02:25:51 GMT
  359. References: <81@drux1.UUCP> <907@umcp-cs.UUCP> <4772@allegra.UUCP> <257@bocklin.UUCP>
  360. Organization: NIH-LEC, Bethesda, MD
  361. Lines: 13
  362. Summary: bit field vs. char
  363.  
  364. --MORE--(55%)In article <257@bocklin.UUCP>, wendt@bocklin.UUCP writes:
  365. > An easy way to determine alignment requirements is to take the size
  366. > of a structure containing one character.  Odd-length structures are
  367. > invariably rounded up to convenient units by the compiler.
  368.  
  369. Or, preferably,
  370.         #define ALIGNMENT (sizeof (struct { char :1;}))
  371. which avoids having to make up a name for a structure element.
  372. --
  373. UNIX is an AT&T Bell Laboratories trademark.
  374. --
  375.         UUCP: ..decvax!seismo!elsie!ado    ARPA: elsie!ado@seismo.ARPA
  376.         DEC, VAX and Elsie are Digital Equipment and Borden trademarks
  377. (Mail) End of article 4725 (of 4956)--what next? [npq] 
  378.  
  379. Article 4726 (230 more) in net.lang.c:
  380. From: edg@well.UUCP (Ed Greenberg)
  381. Subject: Re: C Programming Style -- New thought  ("writing code")
  382. Message-ID: <107@well.UUCP>
  383. Date: 26 Jul 85 16:16:55 GMT
  384. Date-Received: 4 Aug 85 03:17:03 GMT
  385. References: <418@spar.UUCP> <408@utastro.UUCP>
  386. Organization: Whole Earth 'Lectronic Link, Sausalito, CA
  387. Lines: 15
  388. Summary: composing code on paper
  389.  
  390. --MORE--(60%)In article <408@utastro.UUCP>, nather@utastro.UUCP (Ed Nather) writes:
  391. > General question: does anybody "write code" on paper first any more?
  392. > -- 
  393.  
  394. I start to write functions on paper, but you can't use insert
  395. functions on paper!  When I start to stick things in above, I
  396. usually go to the terminal.
  397.  
  398. I DO write pseudocode on paper though.  Sometimes on index
  399. cards.
  400.  
  401.                         -edg
  402.  
  403. {hplabs,dual,ptsfa}!well!micropro!edg
  404. (Mail) End of article 4726 (of 4956)--what next? [npq] 
  405.  
  406. Article 4843 (113 more) in net.lang.c:
  407. From: ark@alice.UUCP (Andrew Koenig)
  408. Subject: Re: how has C bitten you?
  409. Message-ID: <4170@alice.UUCP>
  410. Date: 18 Aug 85 15:07:03 GMT
  411. Date-Received: 24 Aug 85 05:29:41 GMT
  412. References: <228@investor.UUCP>
  413. Organization: Bell Labs, Murray Hill
  414. Lines: 17
  415.  
  416. --MORE--(55%)> int dial(telno)
  417. > char *telno;
  418. > {
  419. >       if(telno){              /*  should be if(*telno)  */
  420. >               dial it;
  421. >       }
  422. >       else{
  423. >               hang up;
  424. >       }
  425. > }
  426.  
  427. Bob Pierce says that this program failed because it should have been
  428. checking *telno instead of telno.
  429.  
  430. If telno is NULL, you had better not look at *telno; it's illegal.
  431. If the address of a legal character item is NULL, your compiler is
  432. not implementing the language properly.
  433. (Mail) End of article 4843 (of 4956)--what next? [npq] 
  434.  
  435. Article 4844 (112 more) in net.lang.c:
  436. From: guy@sun.uucp (Guy Harris)
  437. Subject: Re: What is wrong with this program?
  438. Message-ID: <2654@sun.uucp>
  439. Date: 17 Aug 85 03:43:02 GMT
  440. Date-Received: 24 Aug 85 06:17:17 GMT
  441. References: <117@graffiti.UUCP> <353@ttrdc.UUCP> <9940@ucbvax.ARPA>
  442. Distribution: net
  443. Organization: Sun Microsystems, Inc.
  444. Lines: 14
  445.  
  446. --MORE--(55%)>       Not really, you are forgetting that the format "%.8s" will
  447. > cause printf to print up to a null or 8 chars max.  Unfortunately
  448. > this style of printf can not be used with sizeof for compile time
  449. > format changes without run time code support.
  450.  
  451. True, you can't have the compiler generate the "printf" string, but you can
  452. do
  453.  
  454.         printf("%.*s", sizeof(thing), thing);
  455.  
  456. since you can use "*" for a field width or precision and pick up the value
  457. from the argument list.
  458.  
  459.         Guy Harris
  460. (Mail) End of article 4844 (of 4956)--what next? [npq] 
  461.  
  462. Article 4845 (111 more) in net.lang.c:
  463. From: klong@datlog.UUCP ( Kevin Long )
  464. Newsgroups: net.bugs.usg,net.lang.c
  465. Subject: Possible bug in VAX 11/750 C compiler
  466. Message-ID: <261@datlog.UUCP>
  467. Date: 14 Aug 85 16:20:45 GMT
  468. Date-Received: 24 Aug 85 07:30:38 GMT
  469. Organization: Data Logic Ltd, Greenford, London.
  470. Lines: 51
  471. Xpath: stc stc-a
  472.  
  473. --MORE--(32%)
  474.     Our company is running system 5.2 on a VAX 11/750 and we have a problem with    our compiler in the area of compile time evaluation of constants.
  475.     The problem has appeared after using the system include file values.h to
  476.     define the value MAXSHORT, the maximum value a short can hold.
  477.     This is defined as follows.
  478.  
  479. #define BITSPERBYTE     8
  480. #define BITS(type)      (BITSPERBYTE * (int)sizeof(type))
  481. #define HIBITS          ((short)(1 << BITS(short) - 1))
  482. #define MAXSHORT        ((short)~HIBITS)
  483.  
  484.     After cpp has finished with MAXSHORT it looks like
  485.  
  486. ((short)~((short)(1 << (8 * (int)sizeof(short)) - 1)))
  487.  
  488.     and the compiler treats this at compile time as -32769; (of some size).
  489.     If we now define 
  490.  
  491. int a = 1;
  492.  
  493.     Then neither of the following code works as expected
  494.  
  495. if ( (short) a < MAXSHORT) ....;
  496.  
  497. if ( a < (int) MAXSHORT) ....;
  498.  
  499.     The problem is created by the compiler evaluating constants as longs, signed    unless explicitly told to do otherwise, so the problem goes away if short is    changed to unsigned short in the definitions of MAXSHORT and HIBITS above;
  500.  
  501.     Is this a bug in the compiler or a bad definition in values.h ??
  502. -- 
  503.  
  504.  
  505.                                 Klong
  506.  
  507. The views expressed above are not those of my employer but those of my pet Panda
  508. UUCP: ...!mcvax!ukc!stc!datlog!klong
  509. MAIL: Data Logic Ltd., 320, Ruislip Road East, Greenford, Middlesex, UK.
  510. (Mail) End of article 4845 (of 4956)--what next? [npq] 
  511.  
  512. Article 4846 (110 more) in net.lang.c:
  513. From: lam@btnix.UUCP (lam)
  514. Subject: Re: how has C bitten you? (and a sidetrack)
  515. Message-ID: <16@btnix.UUCP>
  516. Date: 23 Aug 85 10:48:29 GMT
  517. Date-Received: 24 Aug 85 07:31:02 GMT
  518. References: <4051@alice.UUCP> <2600011@ccvaxa>
  519. Organization: British Telecom, Ipswich, England
  520. Lines: 34
  521. Xpath: icdoc ivax
  522.  
  523. --MORE--(32%)[*** The Phantom Article Gobbler Strikes Again ***]
  524. > > >   int i, a[10];
  525. > > >   for (i = 0; i <= 10; i++)
  526. > > >           a[i] = 0;
  527. > > > 
  528.  
  529. > > This looks to me like it will simply overwrite one int's worth of
  530. > > memory beyond the end of the array "a" with the value 0.  Granted,
  531. > > depending on what happens to be after "a", this can have disastrous
  532. > > results, but is there really an implementation in which it will
  533. > > (reliably) lead to infinte looping?
  534. > ----------
  535. > Yes.  Any implementation that allocates the space for i following the
  536. > space for a.
  537.  
  538. The cause of the infinite loop is due to the storage allocation.
  539.         i.e.    &i == &a[10]
  540.    causing i to be overwritten with 0 when i is 10.
  541.  
  542. The more interesting thing is that on some compilers, the infinite
  543.    loop does NOT occur.  Lo and behold, the OPTIMISER comes into play.
  544.    If i is put in a Register at the start of the for(), a[10] = 0 
  545.    will indeed overwrite i in memory but not the register !!! and the
  546.    loop terminates normally.
  547.    What's worse, the optimiser has in this case hidden a program bug!!!
  548.  
  549. Thus the moral:
  550.  
  551.         "Don't just test your code once.  Test it again, this time
  552.          turn the optimiser OFF first".
  553.  
  554. ------------------------------------------------------------------
  555.         Onward Lam 
  556.         CAP Group, Reading, England.
  557. (Mail) End of article 4846 (of 4956)--what next? [npq] 
  558.  
  559. Article 4847 (109 more) in net.lang.c:
  560. From: rbp@investor.UUCP (Bob Peirce)
  561. Subject: Re: how has C bitten you?
  562. Message-ID: <228@investor.UUCP>
  563. Date: 15 Aug 85 23:24:51 GMT
  564. Date-Received: 24 Aug 85 07:31:23 GMT
  565. Organization: Cookson, Peirce & Co., Pittsburgh, PA
  566. Lines: 26
  567.  
  568. --MORE--(48%)Here's one that trapped me this week.  It took much head scratching
  569. and debug prints to figure it out.
  570.  
  571. int dial(telno)
  572. char *telno;
  573. {
  574.         if(telno){              /*  should be if(*telno)  */
  575.                 dial it;
  576.         }
  577.         else{
  578.                 hang up;
  579.         }
  580. }
  581.  
  582. Print statements showed the telno was being handed to the routine,
  583. but the if said nothing was there.  Turns out, on my system, the
  584. address of telno is NULL.  I needed to check the contents not the
  585. address!
  586. -- 
  587.  
  588.                         Bob Peirce, Pittsburgh, PA
  589.                 uucp: ...!{allegra, bellcore, cadre, idis}
  590.                          !pitt!darth!investor!rbp
  591.                                 412-471-5320
  592.  
  593.                 NOTE:  Mail must be < 30,000 bytes/message
  594. (Mail) End of article 4847 (of 4956)--what next? [npq] 
  595.  
  596. Article 4848 (108 more) in net.lang.c:
  597. From: daveb@rtech.UUCP (Dave Brower)
  598. Subject: C Idioms - reference work?
  599. Message-ID: <597@rtech.UUCP>
  600. Date: 16 Aug 85 08:00:52 GMT
  601. Date-Received: 24 Aug 85 07:32:57 GMT
  602. References: <359@tektools.UUCP> <30000008@ISM780.UUCP>
  603. Organization: Relational Technology, Alameda CA
  604. Lines: 11
  605.  
  606. --MORE--(59%)I recall hearing a rumour a year or two ago about a hardcopy reference
  607. to many common 'C' idioms.  It may have come out of some European
  608. University.  Has anyone heard of such a beast, and know where I might
  609. obtain a copy?
  610.  
  611. -dB
  612.  
  613. -- 
  614. {amdahl|dual|sun|zehntel}\              |"If his brains ran down, how could
  615. {ucbvax|decvax}!mtxinu---->!rtech!daveb |he talk?"
  616. ihnp4!{phoenix|amdahl}___/              |"Happens to people all the time...."
  617. (Mail) End of article 4848 (of 4956)--what next? [npq] 
  618.  
  619. Article 4849 (107 more) in net.lang.c:
  620. From: levy@ttrdc.UUCP (Daniel R. Levy)
  621. Subject: Re: how has C bitten you?  (Really, style)
  622. Message-ID: <372@ttrdc.UUCP>
  623. Date: 19 Aug 85 16:41:52 GMT
  624. Date-Received: 24 Aug 85 09:45:17 GMT
  625. References: <302@brl-tgr.ARPA> <4081@alice.UUCP> <243@ecrhub.UUCP> <123@ecsvax.UUCP> <389@phri.UUCP>
  626. Distribution: net
  627. Organization: AT&T, Computer Systems Division, Skokie, IL
  628. Lines: 30
  629.  
  630. --MORE--(33%)In article <389@phri.UUCP>, roy@phri.UUCP (Roy Smith) writes:
  631. >       Here's one that just got me:
  632. >
  633. >               if (sv > score);   <----- note extraneous semi-colon
  634. >                       score = sv;
  635. >
  636. >       This was in a series of computations which gave various scores; the
  637. >fragment above was repeated in various places to pick out the maximum.  Of
  638. >course, the test is a no-op and the assignment was always done.  Naturally,
  639. >this passes lint (even with the -h flag which uses "heuristic tests to
  640. >attempt to intuit bugs") without any complaint.
  641. >--
  642. >Roy Smith <allegra!phri!roy>
  643.  
  644. Sounds like a question of style hiding function.  Why not stick to something
  645. like
  646.  
  647.                 if (sv > score) score = sv;
  648.  
  649. ?
  650.  
  651. I can't think of anything much more straightforward than that.
  652. -- 
  653.  -------------------------------    Disclaimer:  The views contained herein are
  654. |       dan levy | yvel nad      |  my own and are not at all those of my em-
  655. |         an engihacker @        |  ployer, my pets, my plants, my boss, or the
  656. | at&t computer systems division |  s.a. of any computer upon which I may hack.
  657. |        skokie, illinois        |
  658. |          "go for it"           |  Path: ..!ihnp4!ttrdc!levy
  659.  --------------------------------     or: ..!ihnp4!iheds!ttbcad!levy
  660. (Mail) End of article 4849 (of 4956)--what next? [npq] 
  661.  
  662. Article 4851 (105 more) in net.lang.c:
  663. From: stern@bnl.UUCP (eric)
  664. Subject: Re: VAX VMS C / UNIX C Compatibility --
  665. Message-ID: <142@bnl.UUCP>
  666. Date: 17 Aug 85 06:17:25 GMT
  667. Date-Received: 26 Aug 85 02:56:32 GMT
  668. References: <488@rdin.UUCP> <3400003@ndm20>
  669. Organization: Brookhaven National Lab. Upton, N.Y.
  670. Lines: 70
  671.  
  672. --MORE--(13%)> >Another thing I'm looking for under VMS is the ability to load both
  673. > >C and FORTRAN object files into one executable. Does anyone know if
  674. > >this works?
  675. > It is supposed to but some while ago, there was a discussion on 
  676. > INFO-VAX saying that C in some way violated the VMS procedure calling
  677. > standard. Thus there is one or more obscure case that fails. This
  678. > is ironic in that the calling standard is highly touted by DEC. This 
  679. > discussion predated VMS4, so they may have fixed it.
  680.  
  681. I don't know if I would make too much of this.  The procedure calling
  682. calling standard is only that and nothing more.  The fact that I can
  683. violate the standard in C, is just a function of the fact that I can
  684. do most anything in C.  I can violate the standard by doing certain
  685. things in MACRO also, so this is just another example of "I can do
  686. anything in C that I can do in MACRO".  There are rather simple
  687. rules to follow if you are programming in C and are interfacing to
  688. other languages to make a program comply with the procedure calling
  689. standard.  Note that there is no problem if a program is entirely
  690. written in C, so that this problem will not effect the porting
  691. of existing C programs.
  692.  
  693. > There is also a general rule that happens to apply in this case, that
  694. > I/O can only be done from routines in the same language as the main. 
  695. > This is because that is where most compilers on most machines put the
  696. > calls to the I/O system initializers, and few languages share I/O 
  697. > systems. On some machines, you can't even do it if there are routines
  698. > of another language between the main and the routine in question.
  699.  
  700. This may have been the case in an old version of VMS, but it certainly
  701. isn't correct now.  I regularly mix FORTRAN and PASCAL I/O, and I just
  702. verified that I can do C standard I/O mixed with PASCAL I/O.  In VMS
  703. run-time systems, initialized data is linked in the run-time libraries
  704. as initialized copy-on-reference data, and so no initialization needs
  705. to be done at run time.  The biggest problem one is likely to run
  706. into when mixing I/O to the terminal is that FORTRAN, PASCAL, and C
  707. all have different ideas about carriage control, and each maintains
  708. a separate picture of what carriage control characters are necessary.
  709.  
  710. > Terry Poot
  711. > Nathan D. Maier Consulting Engineers
  712. > (214)739-4741
  713. > Usenet: ...!{allegra|ihnp4}!convex!smu!ndm20!tp
  714. > CSNET:  ndm20!tp@smu
  715. > ARPA:   ndm20!tp%smu@csnet-relay.ARPA
  716.  
  717. In general, C programs that do I/O with standard I/O library
  718. interfaces (getc, printf, etc...), use math library functions, and
  719. that don't use things like stat and ioctl can be expected to work
  720. unmodified on VMS systems.  Programs that use (read, write, open, creat)
  721. will work in many cases, although they will have to be looked at
  722. carefully.  In particular, the file formats may cause a problem.
  723. Programs that rely on forking/vforking and pipes will probably
  724. need major changes to run.  DEC supplies an implementation of
  725. vfork and pipes, but it is so limited that I suspect it may not
  726. be useful.  Still, if your program happens to fall within the
  727. limitations, it may run, although with a severe performance problem.
  728. There are many miscellaneous routines supplied for compatabilility with
  729. UNIX, and if a program uses them, there is a large chance it will
  730. work for both UNIX and VMS.  This compatability has expanded a lot
  731. in the last release of the C compiler and I have not had a chance
  732. to fully explore the new stuff.  It looks like there is even a
  733. curses.
  734.  
  735.                                         Eric G. Stern
  736.                                         Dept. of Physics SUNY StonyBrook
  737.                                         stern@bnl.arpa
  738.                                         stern@bnl.bitnet
  739.                                         stern@bnldag.bitnet
  740.                                         ...!philabs!sbcs!bnl!stern
  741. (Mail) End of article 4851 (of 4956)--what next? [npq] 
  742.  
  743. Article 4852 (104 more) in net.lang.c:
  744. From: dimitrov@csd2.UUCP (Isaac Dimitrovsky)
  745. Subject: Bug in lint ?
  746. Message-ID: <3090005@csd2.UUCP>
  747. Date: 20 Aug 85 19:47:00 GMT
  748. Date-Received: 26 Aug 85 03:48:25 GMT
  749. Organization: New York University
  750. Lines: 29
  751.  
  752. --MORE--(39%)[]
  753.  
  754. I've run into a possible bug in lint. It can be reproduced on my system
  755. (VAX 4.2BSD) by running lint -ap on the program below. This produces:
  756.  
  757. try.c:
  758. try.c(5): warning: long assignment may lose accuracy
  759.  
  760. The options a and p are supposed to check for assignments of longs to
  761. ints and incompatibilities with the IBM and GCOS dialects of C,
  762. respectively. Strangely enough, when I just run lint with the a option
  763. or the p option alone, the program goes through with no messages.
  764. Any explanations or ideas welcome.
  765.  
  766. main() {
  767.         long a;
  768.         int i;
  769.  
  770.         a=0; i=1;
  771.         if ((a & (1L<<i)) != 0L)
  772.                 a++;
  773. }
  774.  
  775. Isaac Dimitrovsky
  776. allegra!cmcl2!csd2!dimitrov   (l in cmcl2 is letter l not number 1)
  777. 251 Mercer Street, New York NY 10012
  778.  
  779. ... Hernandez steps in to face ... Orl ... HERchiiiser ... and it's a liiine
  780. driive, deeeeep to the gap in left center ...   - Bob Murphy, Voice of the Mets
  781. (Mail) End of article 4852 (of 4956)--what next? [npq] 
  782.  
  783.  
  784. Article 4854 (102 more) in net.lang.c:
  785. From: freeman@spar.UUCP (Jay Freeman)
  786. Subject: Re: more about programming style
  787. Message-ID: <476@spar.UUCP>
  788. Date: 21 Aug 85 20:39:56 GMT
  789. Date-Received: 26 Aug 85 04:28:15 GMT
  790. References: <11457@brl-tgr.ARPA> <68@ucbcad.UUCP> <1693@reed.UUCP> <441@myriasb.UUCP> <141@rpics.UUCP> <457@lasspvax.UUCP> <1317@eagle.UUCP>21 Aug 85 20:39:56 GMT
  791. Reply-To: freeman@max.UUCP (Jay Freeman)
  792. Organization: Schlumberger Palo Alto Research, CA
  793. Lines: 17
  794.  
  795. --MORE--(48%)[libation to line-eater]
  796.  
  797. In article <16220@watmath.UUCP> rbutterworth@watmath.UUCP (Ray Butterworth) writes:
  798.  
  799. >Even simpler.  Replace "<=" with "!>", and ">=" with "!<".  This gives
  800. >even more consistency since you can now have "!<", "!>", and "!=".
  801.  
  802. I suspect that Ray Butterworth may have had a :-) in mind when he wrote
  803. these lines, but I kind of _like_ "!<" and "!>".  I guess I always think of
  804. "<=" -- for example -- as two separate tests and have to combine both of
  805. them mentally when I am figuring out what something does.  (Or maybe it's
  806. brain-damage from writing too many lines of assembler.)  Anyway, those might
  807. be a reasonable enhancement, and surely would be all but free in terms of
  808. additional compiler complexity.
  809.  
  810.  
  811. -- 
  812. Jay Reynolds Freeman (Schlumberger Palo Alto Research)(canonical disclaimer)
  813. (Mail) End of article 4854 (of 4956)--what next? [npq] 
  814.  
  815. Article 4855 (101 more) in net.lang.c:
  816. From: robert@cheviot.uucp (Robert Stroud)
  817. Subject: Re: Exception Handling?  Impossible!
  818. Message-ID: <414@cheviot.uucp>
  819. Date: 19 Aug 85 16:40:50 GMT
  820. Date-Received: 26 Aug 85 04:36:28 GMT
  821. References: <10200002@ada-uts.UUCP>
  822. Reply-To: robert@cheviot.UUCP (Robert Stroud)
  823. Organization: U. of Newcastle upon Tyne, U.K.
  824. Lines: 25
  825.  
  826. --MORE--(46%)Rich Wagner (richw@ada-uts.UUCP) posted some macros for exception handling
  827. and asked for comments and suggestions.
  828.  
  829. I can recommend an article in Software Practice & Experience by Peter Lee
  830. a few years ago (1983, pp 389-405) which describes a series of macros and
  831. routines which add exception handling in the style of Ada or Clu to C.
  832. Basically they work by hiding a stack of setjmp/longjmp contexts inside
  833. a macro skeleton of
  834.  
  835.         BEGIN
  836.            ...
  837.         EXCEPT
  838.            WHEN(exception1) ...
  839.            WHEN(exception2) ...
  840.            OTHERS ...
  841.         END
  842.  
  843. I can post the code from the article if there is enough interest.
  844.  
  845. Robert Stroud,
  846. Computing Laboratory,
  847. University of Newcastle upon Tyne.
  848.  
  849. UUCP ...!ukc!cheviot!robert
  850. ARPA robert%cheviot.newcastle@ucl-cs.ARPA
  851. (Mail) End of article 4855 (of 4956)--what next? [npq] 
  852.  
  853. Article 4856 (100 more) in net.lang.c:
  854. From: rbp@investor.UUCP (Bob Peirce)
  855. Subject: Re: how has C bitten you? (and a sidetrack)
  856. Message-ID: <229@investor.UUCP>
  857. Date: 19 Aug 85 00:00:19 GMT
  858. Date-Received: 26 Aug 85 04:37:09 GMT
  859. References: <4051@alice.UUCP> <2600011@ccvaxa> <16@btnix.UUCP>
  860. Organization: Cookson, Peirce & Co., Pittsburgh, PA
  861. Lines: 16
  862.  
  863. --MORE--(62%)>    What's worse, the optimiser has in this case hidden a program bug!!!
  864. > Thus the moral:
  865. >       "Don't just test your code once.  Test it again, this time
  866. >        turn the optimiser OFF first".
  867.  
  868. and vice versa!
  869. -- 
  870.  
  871.                         Bob Peirce, Pittsburgh, PA
  872.                 uucp: ...!{allegra, bellcore, cadre, idis}
  873.                          !pitt!darth!investor!rbp
  874.                                 412-471-5320
  875.  
  876.                 NOTE:  Mail must be < 30,000 bytes/message
  877. (Mail) End of article 4856 (of 4956)--what next? [npq] 
  878.  
  879. Article 4857 (99 more) in net.lang.c:
  880. From: guy@sun.uucp (Guy Harris)
  881. Newsgroups: net.lang.c,net.unix
  882. Subject: Re: Not checking printf's result causes another news bug
  883. Message-ID: <2677@sun.uucp>
  884. Date: 20 Aug 85 06:12:30 GMT
  885. Date-Received: 26 Aug 85 04:45:41 GMT
  886. References: <11@brl-tgr.ARPA> <1288@eagle.UUCP> <15908@watmath.UUCP> <116@rtp47.UUCP> <1096@diku.UUCP> <413@brl-Re: Not checking printf's re20 Aug 85 06:12:30 GMT
  887. Followup-To: net.unix
  888. Organization: Sun Microsystems, Inc.
  889. Lines: 36
  890.  
  891. --MORE--(32%)> You could set up a (in unix lingo) a signal handler and if any I/O error
  892. > occurred it would interrupt to that routine. Now this was on a per-write
  893. > (actually, per I/O) basis but what I have in mind here is to do something
  894. > like:
  895. >
  896. > #define printf eprintf
  897. > #define fprintf efprintf
  898. > then add to main() something like
  899. >       signal(SIGIOT,myhandler) ;      /* choose a signal, SIGIOT seems good*/
  900.  
  901. No, SIGIOT is what "abort()" causes (except on 4.xBSD - in System V it uses
  902. "kill" so that you can get SIGIOT even if you don't have an IOT
  903. instruction).  In S3/S5/4.3BSD, you can use SIGUSR1; in older BSD releases,
  904. #define SIGUSR1 as 30, and in V7 #define it as 16.  This signal (as the name
  905. suggests) is reserved for user program use.
  906.  
  907. In System III and System V, though, there is a "software signal" mechanism -
  908. see SSIGNAL(3C).  The claim is made there that "this facility is used by the
  909. Standard C Library to enable users to indicate the disposition of error
  910. signals", but this claims is false; nowhere in the C library is it used.  I
  911. suspect it was intended for this purpose, but nobody bothered changing the
  912. library to use it.  For those of you with non-S3 or S5 systems who have a
  913. source license, you can drop it in.
  914.  
  915. > and something reasonable for myhandler() and finally:
  916. > eprintf(fmt,a,b,c,d,e,f,g...) /* etc or maybe use varargs */
  917. > {
  918.  
  919. Or, preferably, use "vprintf" and its siblings if you have them.  They come
  920. with S3, and with S5R2, but *not* with S5R1.  They can be easily implemented
  921. in any system with "_doprnt" (S5R2 has it and that's how it implements them).
  922.  
  923.         Guy Harris
  924. (Mail) End of article 4857 (of 4956)--what next? [npq] 
  925.  
  926. Article 4858 (98 more) in net.lang.c:
  927. From: cdshaw@watmum.UUCP (Chris Shaw)
  928. Subject: Re: how has C bitten you?  (Really, style)
  929. Message-ID: <259@watmum.UUCP>
  930. Date: 22 Aug 85 00:41:39 GMT
  931. Date-Received: 26 Aug 85 05:10:44 GMT
  932. References: <302@brl-tgr.ARPA> <4081@alice.UUCP> <243@ecrhub.UUCP> <123@ecsvax.UUCP> <389@phri.UUCP> <372@ttrdc.UUCP>
  933. Reply-To: cdshaw@watmum.UUCP (Chris Shaw)
  934. Distribution: net
  935. Organization: U of Waterloo, Ontario
  936. Lines: 44
  937.  
  938. --MORE--(25%)In article <372@ttrdc.UUCP> levy@ttrdc.UUCP (Daniel R. Levy) writes:
  939. >In article <389@phri.UUCP>, roy@phri.UUCP (Roy Smith) writes:
  940. >>      Here's one that just got me:
  941. >>              if (sv > score);   <----- note extraneous semi-colon
  942. >>                      score = sv;
  943. >
  944. >Sounds like a question of style hiding function.  Why not stick to something
  945. >like
  946. >               if (sv > score) score = sv;
  947. >?
  948. >|       dan levy 
  949.  
  950. ...because 
  951.  
  952. if(sv>score||this==that+the_other||fopen("crap","r"))save=the+whales+fur+christ++;
  953.  
  954. is the kind of statement where bugs really happen. Can you seriously spend less
  955. than two seconds reading that to comprehend what's going on ? If you answered
  956. yes, how about this (more important) question: Can you read a whole FILE of
  957. this kind of crap and then be able to find a variable at will ?
  958.  
  959. I doubt it. I can think of more straightforward ways of producing code, some
  960. of which include programming while awake, so that the errors like the
  961. one in the original posting don't happen. Others include using a self-consistentstyle, which Mr Levy's is not. Compound if statements should look the same
  962. as simple if statements.
  963.  
  964. Mr Levy's style of if statement has an equivalent in English called 
  965. "the run-on-sentence". What's silly about the whole thing is that a program
  966. formatter can make this stuff QUITE readable, and will probably find the
  967. bug that "bit" Mr Smith.
  968.  
  969. The most important element of a readable programming style is the use of white
  970. space. I personally can't stand the K&R style because I get visually confused
  971. when I read it. It's similar to an English paragraphing that doesn't use
  972. indenting or spaces between paragraphs. In the C book itself, this isn't bad,
  973. because the program fragments are small and the structures are simple.
  974. In real programs, however, there are lots of programs which are unreadable
  975. until passed through "indent" (on 4.2).
  976.  
  977.  
  978. Chris Shaw    watmath!watmum!cdshaw  or  cdshaw@watmath
  979. University of Waterloo
  980. In doubt?  Eat hot high-speed death -- the experts' choice in gastric vileness !(Mail) End of article 4858 (of 4956)--what next? [npq] 
  981.  
  982. Article 4859 (97 more) in net.lang.c:
  983. From: cdshaw@watmum.UUCP (Chris Shaw)
  984. Subject: Re: VAX VMS C / Rash attempt at porting Kermit
  985. Message-ID: <260@watmum.UUCP>
  986. Date: 22 Aug 85 01:08:01 GMT
  987. Date-Received: 26 Aug 85 05:10:55 GMT
  988. References: <488@rdin.UUCP> <249@watmum.UUCP> <545@osu-eddie.UUCP>
  989. Reply-To: cdshaw@watmum.UUCP (Chris Shaw)
  990. Organization: U of Waterloo, Ontario
  991. Lines: 27
  992.  
  993. --MORE--(32%)In article <545@osu-eddie.UUCP> pritch@osu-eddie.UUCP (Norman Pritchett) writes:>cdshaw writes:
  994. >> VMS is very record-ish, while stream i/o is the unix thing. Unfortunately,
  995. >> port didn't work because we didn't really spend the effort required to do
  996. >> the QIO's required to fake stream i/o on VMS. 
  997. >
  998. >Huh?  On input Vax-11 C converts records with any attribute (implied
  999. >carriage control, print carriage control, FORTRAN carriage control, null,
  1000. >and VFC) to stream format (read your "Programming in VAX-11 C" book
  1001. >AA-L370A-TE) so everything always looks like stream files on input.  On
  1002. >output, Vax-11 C creates stream files unless you go through the immense
  1003. >amount of effort to specify otherwise.
  1004. >-- 
  1005. >Norm Pritchett
  1006.  
  1007. Well, it WAS about 1.5 years ago, but if you'd read my posting, you may have
  1008. noticed the word "Kermit" pop up. You might even know that since Kermit
  1009. is a terminal-bashing program, it requires byte-by-byte I/O. GET IT? We didn't
  1010. want buffering. And we didn't really have a clear idea how to turn it off.
  1011. I vaguely recall that either setbuf wasn't available, or it didn't work,
  1012. or it didn't do what we wanted.
  1013.  
  1014. Anyway, that was ages ago, so don't bug me.
  1015.  
  1016. Chris Shaw    watmath!watmum!cdshaw  or  cdshaw@watmath
  1017. University of Waterloo
  1018. In doubt?  Eat hot high-speed death -- the experts' choice in gastric vileness !(Mail) End of article 4859 (of 4956)--what next? [npq] 
  1019.  
  1020. Article 4860 (96 more) in net.lang.c:
  1021. From: david@ukma.UUCP (David Herron, NPR Lover)
  1022. Subject: Re: Cryptic C
  1023. Message-ID: <2076@ukma.UUCP>
  1024. Date: 22 Aug 85 04:20:06 GMT
  1025. Date-Received: 26 Aug 85 05:12:25 GMT
  1026. References: <2913@ncsu.UUCP> <709@brl-tgr.ARPA> <1056@mtgzz.UUCP> <675@gitpyr.UUCP>
  1027. Reply-To: david@ukma.UUCP (David Herron, NPR Lover)
  1028. Organization: Univ. of KY Mathematical Sciences
  1029. Lines: 31
  1030.  
  1031. --MORE--(37%)In article <675@gitpyr.UUCP> robert@gitpyr.UUCP (Robert Viduya) writes:
  1032. >In article <1056@mtgzz.UUCP>, dsk@mtgzz.UUCP (d.s.klett) writes:
  1033. ...
  1034. >>      typedef enum { False , True } Boolean;
  1035. ...
  1036. >
  1037. >The problem with enums is that compiler allocate them as ints.  This
  1038. >means 1 wasted byte on a machine with a 16-bit int, 3 wasted bytes on
  1039. >a machine with a 32-bit int and so on and so forth.  All you really
  1040. >need is 1 byte (on most conventional machines).  I personally prefer:
  1041. >
  1042. >    #define    TRUE    1
  1043. >    #define    FALSE   0
  1044. >    typedef    char    bool;
  1045.  
  1046. Well, I personally prefer:
  1047.  
  1048.         #define TRUE (1==1)
  1049.         #define FALSE (1==0)
  1050.         typedef char bool;
  1051.  
  1052. Which is succint, to the point, and *machine*independant*!
  1053.  
  1054. 'sides, constant expressions are calculated at compile time anyway.
  1055. -- 
  1056. --- David Herron
  1057. --- ARPA-> ukma!david@ANL-MCS.ARPA
  1058. --- UUCP-> {ucbvax,unmvax,boulder,oddjob}!anlams!ukma!david
  1059. ---        {ihnp4,decvax,ucbvax}!cbosgd!ukma!david
  1060.  
  1061. Hackin's in me blood.  My mother was known as Miss Hacker before she married!
  1062. (Mail) End of article 4860 (of 4956)--what next? [npq] 
  1063.  
  1064. Article 4861 (95 more) in net.lang.c:
  1065. From: dik@zuring.UUCP
  1066. Subject: Re: More Naughty Bits
  1067. Message-ID: <236@zuring.UUCP>
  1068. Date: 21 Aug 85 23:00:30 GMT
  1069. Date-Received: 26 Aug 85 05:18:19 GMT
  1070. References: <575@brl-tgr.ARPA> <132@rtp47.UUCP> <387@uwmcsd1.UUCP> <944@security.UUCP>
  1071. Reply-To: dik@zuring.UUCP (Dik T. Winter)
  1072. Distribution: net
  1073. Organization: CWI, Amsterdam
  1074. Lines: 12
  1075. Apparently-To: rnews@mcvax.LOCAL
  1076.  
  1077. --MORE--(56%)In article <944@security.UUCP> jjg@security.UUCP (Jeff Glass) writes:
  1078. >> (discussion about machines where 0.0 does not have same representation as 0)
  1079. >
  1080. >The CDC Cyber series represents floating-point zero with the (12-bit)
  1081. >exponent zero.  It doesn't matter whether the (48-bit) mantissa is zero
  1082. >or not.
  1083.  
  1084. Not quite, for floating-point multiplication: yes; for floating-point
  1085. addition: no.  (There are numbers such that 2.0*x = 0.0, but x+x /= 0.0)
  1086. -- 
  1087. dik t. winter, cwi, amsterdam, nederland
  1088. UUCP: {seismo|decvax|philabs}!mcvax!dik
  1089. (Mail) End of article 4861 (of 4956)--what next? [npq] 
  1090.  
  1091. Article 4862 (94 more) in net.lang.c:
  1092. From: henry@utzoo.UUCP (Henry Spencer)
  1093. Subject: Re: Cryptic C
  1094. Message-ID: <5884@utzoo.UUCP>
  1095. Date: 19 Aug 85 21:48:35 GMT
  1096. Date-Received: 26 Aug 85 05:20:08 GMT
  1097. References: <2913@ncsu.UUCP>, <709@brl-tgr.ARPA>
  1098. Organization: U of Toronto Zoology
  1099. Lines: 11
  1100.  
  1101. --MORE--(59%)>       typedef int     bool;
  1102. >       #define false   0
  1103. >       #define true    1
  1104.  
  1105. It's interesting to note that Kernighan&Plauger use "yes" and "no" rather
  1106. than "true" and "false", and my own reaction is that the code often reads
  1107. better that way.  Now that's something to *really* start a raging debate
  1108. about... :-)
  1109. -- 
  1110.                                 Henry Spencer @ U of Toronto Zoology
  1111.                                 {allegra,ihnp4,linus,decvax}!utzoo!henry
  1112. (Mail) End of article 4862 (of 4956)--what next? [npq] 
  1113.  
  1114. Article 4863 (93 more) in net.lang.c:
  1115. From: roman@persci.UUCP
  1116. Subject: How do I declare...
  1117. Message-ID: <368@persci.UUCP>
  1118. Date: 21 Aug 85 18:18:56 GMT
  1119. Date-Received: 26 Aug 85 06:09:35 GMT
  1120. Organization: Personal Scientific Corporation, Woodinville, WA, USA, Earth...
  1121. Lines: 32
  1122.  
  1123. --MORE--(30%)Either I'm missing the perfectly obvious or I've found something
  1124. that's impossible to declare in C, even though it makes sense.  I'm
  1125. trying to implement a simple finite state machine with states
  1126. represented by C functions.  Each state function would accept some
  1127. input value as an argument and return a pointer to the function
  1128. implementing the next state, something like this:
  1129.  
  1130. STATE_FUNC (*state)(),   /* the current state         */
  1131.            *state_1(),   /* a function for each state */
  1132.             ... ,
  1133.            *state_n();
  1134.  
  1135.    for (;;) {
  1136.       state = (*state)(get_input());
  1137.    }
  1138.  
  1139. But how is STATE_FUNC typedef'ed?  It's a pointer to a function which
  1140. returns a pointer to a function which returns a pointer...  Any
  1141. suggestions?
  1142.  
  1143. Obviously, there are other ways to implement a finite state machine,
  1144. and I have already chosen one.  Yet this one is conceptually clean, and
  1145. it seems that there must be some way to do it; plus, this could turn
  1146. out to be a more interesting discussion than i++ vs. i = i + 1...
  1147.  
  1148. -- 
  1149. Bill Roman      {ihnp4,decvax,allegra,...}!uw-beaver!tikal!persci!roman
  1150.  
  1151. Summation, Inc, (formerly Personal Scientific Corporation)
  1152. 18702 142nd Ave NE
  1153. Woodinville, WA 98072
  1154. (206) 486-0991
  1155. (Mail) End of article 4863 (of 4956)--what next? [npq] 
  1156.  
  1157. Article 4864 (92 more) in net.lang.c:
  1158. From: ben@cernvax.UUCP (ben)
  1159. Subject: Xinu -- any experience ??
  1160. Message-ID: <211@cernvax.UUCP>
  1161. Date: 20 Aug 85 20:18:57 GMT
  1162. Date-Received: 26 Aug 85 06:17:23 GMT
  1163. Organization: CERN, Geneva/Switzerland
  1164. Lines: 8
  1165.  
  1166. --MORE--(67%)
  1167.   Does anyone out there have experience of making PRACTICAL
  1168. applications using Douglas Comer's Xinu system?  We are
  1169. interested particularly in any real-time applications for
  1170. 68000's.
  1171.  
  1172.    Ben M. Segal,  CERN-DD,  1211 Geneva 23,  Switzerland
  1173.                   (ben@cernvax via mcvax)
  1174. (Mail) End of article 4864 (of 4956)--what next? [npq] 
  1175.  
  1176. Article 4865 (91 more) in net.lang.c:
  1177. From: kdmoen@watcgl.UUCP (Doug Moen)
  1178. Subject: Re: How do I declare... (recursive typedefs)
  1179. Message-ID: <2407@watcgl.UUCP>
  1180. Date: 24 Aug 85 19:42:50 GMT
  1181. Date-Received: 26 Aug 85 06:42:10 GMT
  1182. References: <368@persci.UUCP>
  1183. Reply-To: kdmoen@watcgl.UUCP (Doug Moen)
  1184. Organization: U of Waterloo, Ontario
  1185. Lines: 38
  1186. Summary: You can't do recursive typedefs
  1187.  
  1188. --MORE--(33%)In article <368@persci.UUCP> roman@persci.UUCP writes:
  1189. >Either I'm missing the perfectly obvious or I've found something
  1190. >that's impossible to declare in C, even though it makes sense.  I'm
  1191. >trying to implement a simple finite state machine with states
  1192. >represented by C functions.  Each state function would accept some
  1193. >input value as an argument and return a pointer to the function
  1194. >implementing the next state, something like this:
  1195. >
  1196. >STATE_FUNC (*state)(),   /* the current state         */
  1197. >           *state_1(),   /* a function for each state */
  1198. >            ... ,
  1199. >           *state_n();
  1200. >
  1201. >   for (;;) {
  1202. >      state = (*state)(get_input());
  1203. >   }
  1204. >
  1205. >But how is STATE_FUNC typedef'ed?  It's a pointer to a function which
  1206. >returns a pointer to a function which returns a pointer...  Any
  1207. >suggestions?
  1208.  
  1209. You aren't missing the perfectly obvious.
  1210. Yes, it is impossible to declare in C, even though it makes sense.
  1211.  
  1212. What you want is a recursive typedef:
  1213.         typedef STATE_FUNC (*STATE_FUNC)();
  1214. except that this isn't allowed.
  1215.  
  1216. What you will have to do instead is a kludge:
  1217.         typedef char* (*STATE_FUNC)();
  1218.  
  1219.         for (;;) {
  1220.                 /* Note the cast: */
  1221.                 state = (STATE_FUNC) (*state)(get_input());
  1222.         }
  1223. -- 
  1224. Doug Moen (watmath!watcgl!kdmoen)
  1225. University of Waterloo Computer Graphics Lab
  1226. (Mail) End of article 4865 (of 4956)--what next? [npq] 
  1227.  
  1228. Article 4866 (90 more) in net.lang.c:
  1229. From: pritch@osu-eddie.UUCP (Norman Pritchett)
  1230. Subject: Re: Re: VAX VMS C / Rash attempt at porting Kermit
  1231. Message-ID: <560@osu-eddie.UUCP>
  1232. Date: 24 Aug 85 21:07:38 GMT
  1233. Date-Received: 26 Aug 85 06:50:59 GMT
  1234. References: <488@rdin.UUCP> <249@watmum.UUCP> <545@osu-eddie.UUCP> <260@watmum.UUCP>
  1235. Organization: Ohio State Univ., CIS Dept., Cols, Oh.
  1236. Lines: 24
  1237.  
  1238. --MORE--(40%)> Well, it WAS about 1.5 years ago, but if you'd read my posting, you may have
  1239. > noticed the word "Kermit" pop up. You might even know that since Kermit
  1240. > is a terminal-bashing program,it requires byte-by-byte I/O. GET IT? We didn't
  1241. > want buffering. And we didn't really have a clear idea how to turn it off.
  1242. > I vaguely recall that either setbuf wasn't available, or it didn't work,
  1243. > or it didn't do what we wanted.
  1244. > Anyway, that was ages ago, so don't bug me.
  1245. > Chris Shaw    watmath!watmum!cdshaw  or  cdshaw@watmath
  1246. > University of Waterloo
  1247. > In doubt?  Eat hot high-speed death -- the experts' choice in gastric vileness !
  1248.  
  1249. Duh, oops.  Sorry,  every once in a while the connection doesn't quite make
  1250. it.
  1251.  
  1252.  
  1253. -- 
  1254. -----------------------------------
  1255. Norm Pritchett
  1256. UUCP:   cbosgd!osu-eddie!pritch         P.O. Box 3393
  1257. CSNET:  pritch@ohio-state               Columbus OH 43210
  1258. BITNET: TS1703 at OHSTVMA
  1259. Bellnet: (614) 422-0885
  1260. (Mail) End of article 4866 (of 4956)--what next? [npq] 
  1261.  
  1262. Article 4867 (89 more) in net.lang.c:
  1263. From: root@bu-cs.UUCP (Barry Shein)
  1264. Newsgroups: net.lang.c,net.unix-wizards
  1265. Subject: Re: Re: how has C bitten you?
  1266. Message-ID: <607@bu-cs.UUCP>
  1267. Date: 24 Aug 85 06:58:57 GMT
  1268. Date-Received: 26 Aug 85 06:51:44 GMT
  1269. References: <302@brl-tgr.ARPA> <471@baylor.UUCP>, <148@chinet.UUCP>
  1270. Organization: Boston Univ Comp. Sci.
  1271. Lines: 16
  1272.  
  1273. --MORE--(56%)Not really a bite, but I remember when I was first learning C
  1274. I was quite bewildered by the fact that you couldn't really
  1275. declare your own 'argv', that is, you couldn't declare an
  1276. array of pointers to fixed length buffers except perhaps by:
  1277.  
  1278. char *myargv[] = {
  1279.         "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
  1280.         "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
  1281.  
  1282.         etc
  1283.  
  1284. I mean, argv seemed kinda holy to me, disturbing.
  1285.  
  1286.         -Barry Shein, Boston University
  1287.  
  1288. P.S. I know argv is var length, but that would be even harder to declare!
  1289. (Mail) End of article 4867 (of 4956)--what next? [npq] 
  1290.  
  1291. Article 4868 (88 more) in net.lang.c:
  1292. From: ED@MIT-MC.ARPA (Ed Schwalenberg)
  1293. Subject: Good C compilers for 68000
  1294. Message-ID: <862@brl-tgr.ARPA>
  1295. Date: 21 Aug 85 21:11:41 GMT
  1296. Date-Received: 26 Aug 85 06:59:41 GMT
  1297. Sender: news@brl-tgr.ARPA
  1298. Lines: 16
  1299.  
  1300. --MORE--(34%)We've been using Microsoft's Xenix on Microbar hardware to develop and
  1301. run large C applications.  We have reached the point where our programs
  1302. are too large and too complex for the compiler provided with Xenix.
  1303. Things like limits on the number of #defines, limits on the nesting of
  1304. structures, and the like are giving us fits.  And the code produced by
  1305. this compiler (a descendent of the MIT port of the portable compiler)
  1306. is awful.
  1307.  
  1308. Are there better compilers out there?  Where do I get them?  Microsoft
  1309. refuses to talk with us since Microbar as OEM is supposed to handle
  1310. such things.  Microbar is too busy trying to stay afloat.  Tartan only
  1311. has products for the Vax.  We tried a Whitesmiths product several years
  1312. ago which was even worse, as was a compiler from a company called Alcyon.
  1313. I've heard rumors about the "Green Hills" compiler, but have been unable
  1314. to find out how to get in touch with them.  Any help would be appreciated.
  1315. Please reply to me directly, as I don't subscribe to these lists.
  1316. (Mail) End of article 4868 (of 4956)--what next? [npq] 
  1317.  
  1318. Article 4871 (85 more) in net.lang.c:
  1319. From: cottrell@nbs-vms.ARPA
  1320. Subject: Cryptic Code
  1321. Message-ID: <870@brl-tgr.ARPA>
  1322. Date: 21 Aug 85 23:26:55 GMT
  1323. Date-Received: 26 Aug 85 07:01:21 GMT
  1324. Sender: news@brl-tgr.ARPA
  1325. Lines: 17
  1326.  
  1327. --MORE--(55%)/*
  1328. > Does anyone out there support the author by saying that Version 3 of
  1329. > 'strcpy' is better than Version 2?
  1330.  
  1331. Definitely. You are thinking in terms of another language instead of
  1332. thinking in C. This is like trying to speak french while translating
  1333. to/from english as you go, n'est ce pas?
  1334.  
  1335. > Bob Crane
  1336. > !tektronix!tektools!bobc
  1337. > (503)627-5379
  1338.  
  1339. or you can always try:  stalag13!hogan  :-)
  1340.  
  1341.         jim             cottrell@nbs
  1342. */
  1343. ------
  1344. (Mail) End of article 4871 (of 4956)--what next? [npq] 
  1345.  
  1346. Article 4873 (83 more) in net.lang.c:
  1347. From: cottrell@nbs-vms.ARPA
  1348. Subject: C bites Dog!
  1349. Message-ID: <872@brl-tgr.ARPA>
  1350. Date: 22 Aug 85 01:10:37 GMT
  1351. Date-Received: 26 Aug 85 07:01:54 GMT
  1352. Sender: news@brl-tgr.ARPA
  1353. Lines: 53
  1354.  
  1355. --MORE--(20%)/*
  1356. > > > ???:
  1357. > > >           if (sv > score);   <----- note extraneous semi-colon
  1358. > > >                   score = sv;
  1359. > > Doug Gwyn:
  1360. > > This sort of thing makes me think that a few extra keywords
  1361. > > are called for programming languages like this.  E.g.
  1362. > >     if <bool_expr> then <stmt> fi
  1363. > >     while <bool_expr> do <stmt> od
  1364. > > Something to keep in mind when you design an Algol-like language.
  1365. > ICK ICK ICK! I hate languages that do that. Ever considered using "cb" as a
  1366. > debugging tool? I have an MS-DOS version if anyone wants it...
  1367. > -- 
  1368. >       Peter da Silva (the mad Australian werewolf)
  1369. >               UUCP: ...!shell!neuro1!{hyd-ptd,baylor,datafac}!peter
  1370. >               MCI: PDASILVA; CIS: 70216,1076
  1371.  
  1372. Dear Peter,
  1373.  
  1374.         Welcome to the `Let's Disagree with Doug' club! Unfortunately,
  1375. I am forced to agree with him here. CB (& INDENT) is A Good Thing,
  1376. but since I am such a wonderful coder (:-) I rarely use them. What they
  1377. really are useful for is importing code written by cretins. Also, I
  1378. probably disagree slightly with the output of those formatters. What
  1379. would you do, compare the output of `cb' with the original? Takes
  1380. lots of time & can be visually overlooked.
  1381.  
  1382.         Anyway, to get back to the point, you come to realize that in
  1383.  
  1384.                 if <exp> then <stmt> else <stmt> fi
  1385.  
  1386. the parens around <exp> are unneccesary. And the `fi' makes sure that
  1387. all the elses nest with the correct `if'. The Bourne shell has the
  1388. following definitions, (which many peole dislike, but I think they're OK)
  1389.  
  1390.         #define IF      if(
  1391.         #define THEN    ){
  1392.         #define ELSE    }else{
  1393.         #define FI      }
  1394.  
  1395. The point is, you need at least 4 tokens (or a `one-statement' model)
  1396. to delimit the three parts of an `if' from each other and the outside.
  1397. C uses four (not counting semicolons)in the short form
  1398. (if (e) s1; else s2;) and eight in the long form
  1399. (if (e) { s1; } else { s2; }). And let's get rid of those semicolons 
  1400. too! A newline should imply one. Two statements on a line would need
  1401. an explicit one. An escaped newline would continue to the next line.
  1402. Yeah, I know, write my own language!
  1403.  
  1404.         jim             cottrell@nbs
  1405. */
  1406. ------
  1407. (Mail) End of article 4873 (of 4956)--what next? [npq] 
  1408.  
  1409. Article 4875 (81 more) in net.lang.c:
  1410. From: mikes@3comvax.UUCP (Mike Shannon)
  1411. Subject: C bites / programming style
  1412. Message-ID: <165@3comvax.UUCP>
  1413. Date: 23 Aug 85 17:37:13 GMT
  1414. Date-Received: 26 Aug 85 07:39:49 GMT
  1415. Distribution: net
  1416. Organization: 3Com Corp; Mountain View, CA
  1417. Lines: 14
  1418.  
  1419. --MORE--(51%)With regard to:
  1420.         if(condition);          /* the bug is the seimcolon on this line */
  1421.                 statement;      /* this statement was intended to be
  1422.                                  * executed iff the condition was true
  1423.                                  */
  1424. --------------------
  1425.         I avoid getting bitten in this way by ALWAYS using {}'s after
  1426. if, while, etc.  Even when I have a null statement as the body of an
  1427. while or for, I do it this way:
  1428.         for(i = 0; i < MAX; i++) {
  1429.         }
  1430. Always using braces with if/else also removes ambiguity concerning
  1431. "which if an else belongs to."
  1432.                                 -Michael Shannon (hplabs!oliveb!3comvax!mikes)
  1433. (Mail) End of article 4875 (of 4956)--what next? [npq] 
  1434.  
  1435. Article 4876 (80 more) in net.lang.c:
  1436. From: eppstein@columbia.UUCP (David Eppstein)
  1437. Subject: Re: How do I declare...
  1438. Message-ID: <969@columbia.UUCP>
  1439. Date: 25 Aug 85 00:08:06 GMT
  1440. Date-Received: 26 Aug 85 22:58:10 GMT
  1441. References: <368@persci.UUCP>
  1442. Reply-To: eppstein@columbia.UUCP (David Eppstein)
  1443. Organization: Columbia University
  1444. Lines: 9
  1445.  
  1446. --MORE--(56%)In article <368@persci.UUCP> roman@persci.UUCP writes:
  1447. > Either I'm missing the perfectly obvious or I've found something
  1448. > that's impossible to declare in C, even though it makes sense.  I'm
  1449. > trying to implement a simple finite state machine with states
  1450. > represented by C functions.  Each state function would accept some
  1451. > input value as an argument and return a pointer to the function
  1452. > implementing the next state...
  1453.  
  1454. It works if you imbed them in a struct.  Kind of ugly though.
  1455. (Mail) End of article 4876 (of 4956)--what next? [npq] 
  1456.  
  1457. Article 4877 (79 more) in net.lang.c:
  1458. From: rlk@chinet.UUCP (Richard L. Klappal)
  1459. Subject: Re: Cryptic C
  1460. Message-ID: <156@chinet.UUCP>
  1461. Date: 25 Aug 85 08:38:34 GMT
  1462. Date-Received: 26 Aug 85 22:59:32 GMT
  1463. References: <2913@ncsu.UUCP> <709@brl-tgr.ARPA> <1056@mtgzz.UUCP> <2076@ukma.UUCP> <685@gitpyr.UUCP>
  1464. Reply-To: rlk@chinet.UUCP (Richard L. Klappal)
  1465. Organization: chinet, Public Access UN*X, Chicago
  1466. Lines: 52
  1467. Summary: 
  1468.  
  1469. --MORE--(26%)In article <685@gitpyr.UUCP> robert@gitpyr.UUCP (Robert Viduya) writes:
  1470. >In article <2076@ukma.UUCP>, david@ukma.UUCP (David Herron, NPR Lover) writes:
  1471. >> In article <675@gitpyr.UUCP> robert@gitpyr.UUCP (Robert Viduya) writes:
  1472. >> >
  1473. >> > ... I personally prefer:
  1474. >> >
  1475. >> >    #define TRUE    1
  1476. >> >    #define FALSE   0
  1477. >> >    typedef char    bool;
  1478. >> 
  1479. >> Well, I personally prefer:
  1480. >> 
  1481. >>      #define TRUE (1==1)
  1482. >>      #define FALSE (1==0)
  1483. >>      typedef char bool;
  1484. >> 
  1485. >> Which is succint, to the point, and *machine*independant*!
  1486. >> 
  1487. >
  1488. >Oh?  On what machine is (1==1) equal to 0, or (1==0) not equal to 0?  In
  1489. >section 7.6 (Relational operators, Appendix A - C Reference Manual from
  1490. >K&R's The C Programming Language), it explicitly states that the logical
  1491. >operators all yield 0 if the relation is false and 1 if the relation is
  1492. >true.  Nothing is mentioned about possible variations due to implementation
  1493. >machine differences.
  1494. >
  1495. >                               robert
  1496. >-- 
  1497. >Robert Viduya                                                  01111000
  1498. Maybe not 'machine independent' in C, but the logic will
  1499. be 'language independent' (using the appropriate equality operator).
  1500.  
  1501. I've had to debug an awful lot of assembly language where
  1502. a cpu 'Z' flag (zero-flag) was used as TRUE.  About like strcmp
  1503. returns 0 if two strings are the same so that you cannot extend
  1504. the concept 
  1505.  
  1506.         if (string1==string2) {...}
  1507.  
  1508. that works in F77, PL/I, BASIC, etc.
  1509.  
  1510.  
  1511.  
  1512. Richard Klappal
  1513.  
  1514. UUCP:           ..!ihnp4!chinet!uklpl!rlk  | "Money is truthful.  If a man
  1515. MCIMail:        rklappal                   | speaks of his honor, make him
  1516. Compuserve:     74106,1021                 | pay cash."
  1517. USPS:           1 S 299 Danby Street       | 
  1518.                 Villa Park IL 60181        |    Lazarus Long 
  1519. TEL:            (312) 620-4988             |        (aka R. Heinlein)
  1520. -------------------------------------------------------------------------
  1521. (Mail) End of article 4877 (of 4956)--what next? [npq] 
  1522.  
  1523. Article 4878 (78 more) in net.lang.c:
  1524. From: ark@alice.UucP (Andrew Koenig)
  1525. Subject: Re: Cryptic C
  1526. Message-ID: <4209@alice.UUCP>
  1527. Date: 25 Aug 85 15:38:12 GMT
  1528. Date-Received: 26 Aug 85 23:02:42 GMT
  1529. References: <2083@ukma.UUCP>
  1530. Organization: Bell Labs, Murray Hill
  1531. Lines: 13
  1532.  
  1533. --MORE--(46%)> I have always thought that to be a machine dependancy (the value of true and
  1534. > false).  Maybe I'm wrong.  But, different machines DO have different ideas
  1535. > of which is true and false (at the assembler level).  And it is simply
  1536. > a convention.
  1537.  
  1538. You are wrong: the value of true and false in C is defined as part of
  1539. the language:
  1540.  
  1541. When I write    if(exp) foo(); else bar();   foo is called if exp is
  1542. nonzero and bar is called if exp is zero.
  1543.  
  1544. The result of relational operators, &&, ||, and ! is always 1 or 0
  1545. (not some random machine-dependent value or zero).
  1546. (Mail) End of article 4878 (of 4956)--what next? [npq] 
  1547.  
  1548. Article 4879 (77 more) in net.lang.c:
  1549. From: arnold@gatech.CSNET (Arnold Robbins)
  1550. Subject: Re: How do I declare...
  1551. Message-ID: <1001@gatech.CSNET>
  1552. Date: 25 Aug 85 17:38:54 GMT
  1553. Date-Received: 27 Aug 85 00:42:07 GMT
  1554. References: <368@persci.UUCP> <159@rtp47.UUCP>
  1555. Organization: Pr1mebusters!
  1556. Lines: 23
  1557.  
  1558. --MORE--(39%)
  1559.  
  1560. Article 4880 (76 more) in net.lang.c:
  1561. From: ado@elsie.UUCP (Arthur David Olson)
  1562. Subject: Re: Cryptic C
  1563. Message-ID: <5208@elsie.UUCP>
  1564. Date: 24 Aug 85 16:21:43 GMT
  1565. Date-Received: 27 Aug 85 03:16:26 GMT
  1566. References: <2913@ncsu.UUCP> <709@brl-tgr.ARPA> <1056@mtgzz.UUCP> <2076@ukma.UUCP> <685@gitpyr.UUCP>
  1567. Organization: NIH-LEC, Bethesda, MD
  1568. Lines: 29
  1569. Summary: The good news and the other news about (1==1)
  1570.  
  1571. --MORE--(44%)> > > . . .I personally prefer:
  1572. > > >
  1573. > > >    #define        TRUE    1
  1574. > > >    #define        FALSE   0
  1575. > > > . . .
  1576. > > . . .I personally prefer:
  1577. > > 
  1578. > >     #define TRUE (1==1)
  1579. > >     #define FALSE (1==0)
  1580. > > . . .
  1581. > Oh?  On what machine is (1==1) equal to 0, or (1==0) not equal to 0? . . .
  1582.  
  1583. Yes, the good book (K&R) says that (1==1) is always 1.
  1584. The advantage of the second approach above is that it obviates the need to
  1585. remember this fact.  The disadvantage of the second approach above is that it
  1586. gives "lint" fits ("constant in conditional context").
  1587.  
  1588. As for what *I* prefer:
  1589.  
  1590.         #ifndef TRUE
  1591.         #define TRUE    (1)
  1592.         #define FALSE   (0)
  1593.         #endif
  1594.  
  1595. where the parenthesized definitions match those in "curses.h" to ensure that
  1596. if a reference to "curses.h" appears after the above lines I won't get a
  1597. "macro redefined to a different value" diagnostic from the C preprocessor.
  1598.  
  1599.                                 --ado
  1600. (Mail) End of article 4880 (of 4956)--what next? [npq] 
  1601.  
  1602. Article 4881 (75 more) in net.lang.c:
  1603. From: landauer@drivax.UUCP (Doug Landauer)
  1604. Subject: Re: Cryptic C (Actually typedef ? boolean;)
  1605. Message-ID: <212@drivax.UUCP>
  1606. Date: 20 Aug 85 19:08:04 GMT
  1607. Date-Received: 27 Aug 85 08:32:23 GMT
  1608. References: <2913@ncsu.UUCP> <709@brl-tgr.ARPA>
  1609. Organization: Digital Research, Monterey, CA
  1610. Lines: 17
  1611.  
  1612. --MORE--(56%)Doug Gwyn says:
  1613. > I am pretty conservative when it comes to defining one's own
  1614. > language extensions, this one seems like a winner:
  1615. >       typedef int     bool;
  1616. >       #define false   0
  1617. >       #define true    1
  1618.  
  1619. My favorite way to do this one is
  1620.         typedef enum { false, true } boolean ;
  1621.  
  1622. It provides a little more type checking than your typedef.
  1623. --
  1624.                         -- Doug Landauer --
  1625.         ...[ ihnp4 | mot | ucscc | amdahl ] !drivax!landauer
  1626.                 -- "I survived the DRI layoffs." --
  1627.                         -- "(So far!)" --
  1628. (Mail) End of article 4881 (of 4956)--what next? [npq] 
  1629.  
  1630. Article 4882 (74 more) in net.lang.c:
  1631. From: alexis@reed.UUCP (Alexis Dimitriadis)
  1632. Subject: Re: C bites Dog!
  1633. Message-ID: <1835@reed.UUCP>
  1634. Date: 25 Aug 85 05:25:22 GMT
  1635. Date-Received: 27 Aug 85 10:34:26 GMT
  1636. References: <872@brl-tgr.ARPA>
  1637. Reply-To: alexis@reed.UUCP (Alexis Dimitriadis)
  1638. Organization: Reed College, Portland, Oregon
  1639. Lines: 70
  1640. Summary: 
  1641.  
  1642. --MORE--(16%)> > > >                 if (sv > score);   <----- note extraneous semi-colon
  1643. > > > >                         score = sv;
  1644. > > ICK ICK ICK! I hate languages that do that. Ever considered using "cb" as a
  1645. > > debugging tool? I have an MS-DOS version if anyone wants it...
  1646. > [...]  What
  1647. > would you do, compare the output of `cb' with the original? Takes
  1648. > lots of time & can be visually overlooked.
  1649.  
  1650.   Here is an idea I've had on the back burner for while: How about a
  1651. program that checks the formatting of the source code for consistency?
  1652.   - Take a C beautifier.  
  1653.   - Modify the lexical analyzer so it passes the amount of indentation
  1654.     preceding the line each input statement is on.
  1655.   - Now for each statement, check the _relative_ indentation.  A normal
  1656.     statement should be indented exactly as far as the previous statement;
  1657.     the subordinate part of an "if" or a loop should be further indented,
  1658.     or be on the same line; lines that contain continuation of an expression
  1659.     can start anywhere, and do not affect the expected indent; etc.
  1660.   - If the input disagrees, give a diagnostic.
  1661.  
  1662.   This should catch things like
  1663.     if (tv.set == junk);
  1664.         turn(off);
  1665. or even
  1666.     while (cat == away)
  1667.         mice(dance);
  1668.         cheese--;
  1669. since the "while" should be aligned with the "cheese".  Of course,
  1670. it would be powerless with
  1671.     if (procter & gamble); chips++;
  1672. unless you put in a rule about multiple equal-level statements on the
  1673. same line, which would create problems with macro expansion, etc.
  1674.  
  1675.   Now I haven't started work on this yet, (first I finish my thesis),
  1676. but it seems it could be made to work consistently, and without a lot
  1677. of false alarms.  However, a friend who may know better disagrees.
  1678. Are there really impossible obstacles to the task?  I know the lexical
  1679. analyzer would have to keep track of the offset, and probably line
  1680. number, of every token, but that's no big deal.
  1681.  
  1682.   Could it cope with the thousands of indenting styles?  I think the
  1683. test is general anough to cope with anything.  Since there are so many
  1684. places braces can be, they could be just ingored.
  1685.  
  1686.   Is it a pipe dream? Has it been done before?  (If it has, it must be
  1687. a well kept secret!).  What should I watch out for? Whose code would
  1688. it gag on?  If you have the answers to any of this, (or even some good
  1689. questions), I would appreciate hearing from you.
  1690.  
  1691.   Finally, I apologize for the length of this, and please! none of the
  1692. above condones of condemns any particular style of indenting, the
  1693. subject has been trashed to death anyway.  I have kept the results of
  1694. the indenting style survey, I will mail them to anyone interested.
  1695.  
  1696. Thanks for your attention,
  1697. Alexis Dimitriadis 
  1698.  
  1699.   PS. I have lost the name of the person who conducted the survey.  If
  1700. you still have the "other style" answers, could you send me a list?
  1701. -- 
  1702. _______________________________________________
  1703.   As soon as I get a full time job, the opinions expressed above
  1704. will attach themselves to my employer, who will never be rid of
  1705. them again.
  1706.  
  1707.              alexis @ reed
  1708.  
  1709.                  ...teneron! \
  1710. ...seismo!ihnp4! - tektronix! - reed.UUCP
  1711.      ...decvax! /
  1712. (Mail) End of article 4882 (of 4956)--what next? [npq] 
  1713.  
  1714. Article 4883 (73 more) in net.lang.c:
  1715. From: david@ukma.UUCP (David Herron, NPR Lover)
  1716. Subject: Re: Cryptic C
  1717. Message-ID: <2083@ukma.UUCP>
  1718. Date: 25 Aug 85 06:37:23 GMT
  1719. Date-Received: 27 Aug 85 11:06:59 GMT
  1720. References: <2913@ncsu.UUCP> <709@brl-tgr.ARPA> <1056@mtgzz.UUCP> <2076@ukma.UUCP> <685@gitpyr.UUCP>
  1721. Reply-To: david@ukma.UUCP (David Herron, NPR Lover)
  1722. Organization: Univ. of KY Mathematical Sciences
  1723. Lines: 47
  1724.  
  1725. --MORE--(22%)In article <685@gitpyr.UUCP> robert@gitpyr.UUCP (Robert Viduya) writes:
  1726. >In article <2076@ukma.UUCP>, david@ukma.UUCP (David Herron, NPR Lover) writes:
  1727. >> Well, I personally prefer:
  1728. >> 
  1729. >>      #define TRUE (1==1)
  1730. >>      #define FALSE (1==0)
  1731. >>      typedef char bool;
  1732. >> 
  1733. >> Which is succint, to the point, and *machine*independant*!
  1734. >> 
  1735. >
  1736. >Oh?  On what machine is (1==1) equal to 0, or (1==0) not equal to 0?  In
  1737. >section 7.6 (Relational operators, Appendix A - C Reference Manual from
  1738. >K&R's The C Programming Language), it explicitly states that the logical
  1739. >operators all yield 0 if the relation is false and 1 if the relation is
  1740. >true.  Nothing is mentioned about possible variations due to implementation
  1741. >machine differences.
  1742.  
  1743. I don't particularly care if it's defined to be machine independant already.
  1744.  
  1745. I have always thought that to be a machine dependancy (the value of true and
  1746. false).  Maybe I'm wrong.  But, different machines DO have different ideas
  1747. of which is true and false (at the assembler level).  And it is simply
  1748. a convention.
  1749.  
  1750. Still though, #define TRUE (1==1) is very obvious, to the point, correct,
  1751. proper, and all sorts of things.  And it doesn't require one to know
  1752. that detail about C that the convention is ~0 == TRUE and 0 == FALSE.
  1753.  
  1754. When I'm writing C I think of it has a *high*level*language*.  Not as 
  1755. simply one step away from assembler.  The difference between C and other 
  1756. *high*level*languages* is that it gives you precise control over an 
  1757. idealized machine.  This is what confuses most people about C, because
  1758. it can *feel* like assembler.  Especially when they've learned it on a 
  1759. PDP-11 and think like an assembly programmer.
  1760.  
  1761. But C gives you all these operators which allow you to define things
  1762. machine independantly rather than hardcoding values.  Obviously I mean
  1763. casts and the sizeof operator.  Also arithmetic to pointers.  So why not
  1764. TRUE and FALSE?
  1765. -- 
  1766. --- David Herron
  1767. --- ARPA-> ukma!david@ANL-MCS.ARPA
  1768. --- UUCP-> {ucbvax,unmvax,boulder,oddjob}!anlams!ukma!david
  1769. ---        {ihnp4,decvax,ucbvax}!cbosgd!ukma!david
  1770.  
  1771. Hackin's in me blood.  My mother was known as Miss Hacker before she married!
  1772. (Mail) End of article 4883 (of 4956)--what next? [npq] 
  1773.  
  1774. Article 4884 (72 more) in net.lang.c:
  1775. From: guy@sun.uucp (Guy Harris)
  1776. Subject: Re: how has C bitten you?
  1777. Message-ID: <2702@sun.uucp>
  1778. Date: 24 Aug 85 22:43:37 GMT
  1779. Date-Received: 28 Aug 85 03:02:59 GMT
  1780. References: <228@investor.UUCP> <132@mcgill-vision.UUCP>
  1781. Organization: Sun Microsystems, Inc.
  1782. Lines: 62
  1783.  
  1784. --MORE--(20%)>   [ ... ]
  1785. > >     if(telno){              /*  should be if(*telno)  */
  1786. >   [ ... ]
  1787. > > Print statements showed the telno was being handed to the routine,
  1788. > > but the if said nothing was there.  Turns out, on my system, the
  1789. > > address of telno is NULL.  I needed to check the contents not the
  1790. > > address!
  1791. > Gee....and I thought a zero pointer was guaranteed not to point to
  1792. > anything valid (K&R says this).
  1793.  
  1794. All valid implementations of C guarantee this.  Obviously, the
  1795. implementation of C that this was done on is not valid.  He should complain
  1796. to the vendor.  (Yes, there have been such implementations; one well-known
  1797. chip maker's first UNIX release didn't put the necessary shim at data
  1798. location 0 on a separate I&D space program.  They fixed it shortly
  1799. afterwards.)
  1800.  
  1801. > Or is NULL not a zero?!  No, you are comparing to 0 not NULL.
  1802.  
  1803. If you compare a pointer against 0, the actual code compiled compares it
  1804. against a null pointer.  NULL *is* 0, if you're talking from the standpoint
  1805. of "what does the '#define' in <stdio.h> and other places say":
  1806.  
  1807.         /*      @(#)stdio.h 1.2 85/01/21 SMI; from UCB 1.4 06/30/83     */
  1808.  
  1809.         ...
  1810.  
  1811.         #define NULL    0
  1812.  
  1813. (and you'll find the same thing in V7, 4.2, 4.3, S3, S5, ...).  In any
  1814. context where it is known to the compiler that something is supposed to be a
  1815. pointer to a specific data type, any zero that appears there is treated as a
  1816. null pointer of the type "pointer to that data type" (obviously, not a null
  1817. pointer to an object of that data type, since a null pointer can't point to
  1818. anything).  These contexts include comparisons and assignments, so the two
  1819. assignments in
  1820.  
  1821.         register struct frobozz *p;
  1822.  
  1823.         p = 0;
  1824.         p = (struct frobozz *)0;
  1825.  
  1826. are equivalent and the two comparisons in
  1827.  
  1828.         if (p == 0)
  1829.                 foo();
  1830.         if (p == (struct frobozz *)0)
  1831.                 foo();
  1832.  
  1833. are equivalent.  Procedure calls, however, are not such a context, so the
  1834. two procedure calls in
  1835.  
  1836.         bar(0);
  1837.         bar((struct frobozz *)0);
  1838.  
  1839. are very definitely *not* equivalent.  In ANSI Standard C, there is a syntax
  1840. to specify that "bar" takes an argument of type "struct frobozz *"; if you
  1841. declared "bar" in such a manner, the two procedure calls would be equivalent.
  1842.  
  1843.         Guy Harris
  1844. (Mail) End of article 4884 (of 4956)--what next? [npq] 
  1845.  
  1846.  
  1847. Article 4886 (70 more) in net.lang.c:
  1848. From: gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>)
  1849. Subject: Re: Cryptic C
  1850. Message-ID: <904@brl-tgr.ARPA>
  1851. Date: 22 Aug 85 21:57:19 GMT
  1852. Date-Received: 28 Aug 85 03:03:49 GMT
  1853. References: <2913@ncsu.UUCP> <709@brl-tgr.ARPA> <1056@mtgzz.UUCP>
  1854. Organization: Ballistic Research Lab
  1855. Lines: 3
  1856.  
  1857. --MORE--(77%)The reason I didn't use char or enum for boolean data definition
  1858. is that that is not how C actually works.  Int is a more accurate
  1859. representation of the current state of affairs.
  1860. (Mail) End of article 4886 (of 4956)--what next? [npq] 
  1861.  
  1862. Article 4887 (69 more) in net.lang.c:
  1863. From: gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>)
  1864. Subject: Re: Cryptic C
  1865. Message-ID: <905@brl-tgr.ARPA>
  1866. Date: 22 Aug 85 21:59:24 GMT
  1867. Date-Received: 28 Aug 85 03:03:56 GMT
  1868. References: <2913@ncsu.UUCP>, <709@brl-tgr.ARPA> <5884@utzoo.UUCP>
  1869. Organization: Ballistic Research Lab
  1870. Lines: 5
  1871.  
  1872. --MORE--(72%)> It's interesting to note that Kernighan&Plauger use "yes" and "no" rather
  1873. > than "true" and "false", ...
  1874.  
  1875. Yes, but the conventional use in symbolic logic is true/false.
  1876. One is not always asking a natural yes/no question of a predicate.
  1877. (Mail) End of article 4887 (of 4956)--what next? [npq] 
  1878.  
  1879. Article 4888 (68 more) in net.lang.c:
  1880. From: mbr@aoa.UUCP (Mark Rosenthal)
  1881. Subject: Suggestion to enhance code readability
  1882. Message-ID: <255@aoa.UUCP>
  1883. Date: 22 Aug 85 23:21:32 GMT
  1884. Date-Received: 28 Aug 85 03:05:00 GMT
  1885. References: <11457@brl-tgr.ARPA> <68@ucbcad.UUCP> <1693@reed.UUCP>
  1886. Distribution: net
  1887. Organization: Adaptive Optics Assoc., Cambridge, Mass. USA
  1888. Lines: 30
  1889.  
  1890. --MORE--(33%)Although our site has been receiving articles for the past few months,
  1891. articles posted to the net have not been getting distributed until recently.
  1892. The following is a reposting of an article I sent out quite some time ago.
  1893. I believe it never made it to the net at large.  Apologies if you have seen
  1894. this before.
  1895. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1896.  
  1897. Alexis Dimitriadis (alexis @ reed) writes:
  1898.  
  1899. >   Expressions like "while (var++) ;" introduce problems that take
  1900. > (bitter) experience before they can be handily detected, even if the
  1901. > reader is familiar with the semantics of the expression.  That is the
  1902. > real reason it takes a seasoned C programmer to debug seasoned C code.
  1903.  
  1904. Since every simple C statement ends with a ";", it is easy to misread
  1905. the ";" in the above as a terminator for the while statement, rather
  1906. than a terminator for a null statement controlled by the while.  Placing
  1907. the ";" on the same line as the while makes this misinterpretation very
  1908. likely.  That is why I came up with the following (equivalent) construction,
  1909. which I have been using for several years.  I believe it enhances readability.
  1910. But then, I have weird tastes.
  1911.  
  1912.         while (var++)
  1913.             { }
  1914.  
  1915.  
  1916. -- 
  1917.  
  1918.         Mark of the Valley of Roses
  1919.         ...!{decvax,linus,ima,ihnp4}!bbncca!aoa!mbr
  1920. (Mail) End of article 4888 (of 4956)--what next? [npq] 
  1921.  
  1922. Article 4889 (67 more) in net.lang.c:
  1923. From: ee161bep@sdcc3.UUCP (Paul Van de Graaf)
  1924. Subject: Re: C bites Dog!
  1925. Message-ID: <2968@sdcc3.UUCP>
  1926. Date: 24 Aug 85 10:33:25 GMT
  1927. Date-Received: 28 Aug 85 03:07:51 GMT
  1928. References: <872@brl-tgr.ARPA>
  1929. Reply-To: ee161bep@sdcc3.UUCP (Paul Van de Graaf{|stu)
  1930. Organization: U.C. San Diego, Academic Computer Center
  1931. Lines: 28
  1932.  
  1933. --MORE--(27%)In article <872@brl-tgr.ARPA> cottrell@nbs-vms.ARPA writes:
  1934. >The point is, you need at least 4 tokens (or a `one-statement' model)
  1935. >to delimit the three parts of an `if' from each other and the outside.
  1936. >C uses four (not counting semicolons)in the short form
  1937. >(if (e) s1; else s2;) and eight in the long form
  1938. >(if (e) { s1; } else { s2; }). And let's get rid of those semicolons 
  1939. >too! A newline should imply one. Two statements on a line would need
  1940. >an explicit one. An escaped newline would continue to the next line.
  1941. >Yeah, I know, write my own language!
  1942. >
  1943. >       jim             cottrell@nbs
  1944.  
  1945.         Couldn't agree with Jim more!  Especially on the no semi-colon point.
  1946. I use Action! (a C/Pascal/Basic derivative) on my Atari, and it has this
  1947. feature.  If Action! had all of C's operators, had more reasonable data types
  1948. (better struct/unions etc.), AND supported recursion, I'd never look back.
  1949. Action also has the if <> then <> fi style bracketing which I suppose was
  1950. inspired by the Bourne shell.  I personally don't like the case .. esac stuff
  1951. in the Bourne shell, but I can't understand why C programmers are so concerned
  1952. about typing 2 to 5 letter keywords instead of (, ), {, and }.  I don't type
  1953. special characters very well, and I think it's because of having to hit that
  1954. <shift> key.  The QWERTY system is at its best when typing alphas; anything
  1955. else slows you down, especially when you have to look for the "weird" keys
  1956. that various brain-damaged manufacturers put in all kinds of crazy positions.
  1957. I'm ready for something beyond C, and I don't mean C++ or Ada.  If no one
  1958. obliges all just have to do as Jim says and write my own.
  1959.  
  1960. Paul van de Graaf       sdcsvax!sdcc3!ee161bep          U. C. San Diego
  1961. (Mail) End of article 4889 (of 4956)--what next? [npq] 
  1962.  
  1963.  
  1964. Article 4893 (63 more) in net.lang.c:
  1965. From: roy@phri.UUCP (Roy Smith)
  1966. Subject: Re: C bites / programming style [if (cond); statement;]
  1967. Message-ID: <418@phri.UUCP>
  1968. Date: 25 Aug 85 19:11:01 GMT
  1969. Date-Received: 28 Aug 85 04:16:51 GMT
  1970. References: <165@3comvax.UUCP>
  1971. Distribution: net
  1972. Organization: Public Health Research Inst. (NY, NY)
  1973. Lines: 62
  1974.  
  1975. --MORE--(16%)>       I avoid getting bitten in this way by ALWAYS using {}'s after
  1976. > if, while, etc.  Even when I have a null statement as the body [...]
  1977. > -Michael Shannon (hplabs!oliveb!3comvax!mikes)
  1978.  
  1979.         Since I was the original poster of this particular bite, let me
  1980. add a few random comments.  First off, I'm really kind of amazed how much
  1981. discussion this is getting.  I wish people would pay this much attention
  1982. when I do things correctly!
  1983.  
  1984.         Oddly enough, part of the bite was from emacs.  Since the code in
  1985. question was repeated several times with small changes, I wrote it once and
  1986. used a macro to duplicate and modify it each time.  My real goof was in
  1987. defining the emacs macro.  I somehow dragged the extra semi-colon along
  1988. causing an error I probably wouldn't have made if I wrote each fragment by
  1989. hand.  Shows me to try and be clever.
  1990.  
  1991.         I put null loop-bodies on a separate line like in the following
  1992. example.  You all know how I write null if-bodies. :-)
  1993.  
  1994.                 while (eatup() != '\n')
  1995.                         ;
  1996.  
  1997.         If the body of the [whatever] is a single simple statement, I leave
  1998. out the braces and do something like the following (I'm using "simple" in
  1999. the generic sense, not strictly as defined by the C grammer):
  2000.  
  2001.         if (foo >= bar)         |       while (*foo++ == bar)
  2002.                 sum += foo;     |               printf ("still a bar\n");
  2003.         else                    |
  2004.                 toosmall++;     |
  2005.  
  2006.         If the body is more complicated than an assignment or function
  2007. call, I put it in braces, even though they really aren't needed, thus:
  2008.  
  2009.         while ((foo = getfoo()) != EOF) |
  2010.         {                               |       for (x=0; x <= 10; x++)
  2011.                 if (foo >= bar)         |       {
  2012.                         sum += foo;     |               for (y=0; y <= 10; y++)
  2013.                 else                    |                       sumxy += x * y;
  2014.                         toosmall++;     |       }
  2015.         }                               |
  2016.  
  2017.         The entire "if-else" or "for" construct is a single statement, but
  2018. intuitively I think about lines and statements being the same (probably a
  2019. holdover from my Fortran days).  If I write a multi-line statement, I put
  2020. braces around it to make that clear (to myself, if nobody else).  Actually,
  2021. in the "for" example above, I would probably drop the braces.  If, however,
  2022. the inner loop needed braces, the outer one would be sure to get them too.
  2023.  
  2024.         A few people have suggested I run my source through a code grinder
  2025. like "cb".  If the output of cb is different from its input, it's a hint I
  2026. goofed somewhere.  Something like "cb < foo.c | diff foo.c -" would do the
  2027. job nicely.  While this is a good idea, I don't see why this isn't built
  2028. into "lint".
  2029.  
  2030.         OK, now can we please start working on somebody else's boo-boos?
  2031. It's embarrassing to see my dirty laundry come back at me 6 times a day,
  2032. even if it is somewhat amusing.
  2033. -- 
  2034. Roy Smith <allegra!phri!roy>
  2035. System Administrator, Public Health Research Institute
  2036. 455 First Avenue, New York, NY 10016
  2037. (Mail) End of article 4893 (of 4956)--what next? [npq] 
  2038.  
  2039. Article 4894 (62 more) in net.lang.c:
  2040. From: jayf@islenet.UUCP (Jay Fields)
  2041. Newsgroups: net.lang.c,net.micro.mac
  2042. Subject: help with sizeof() in HIPPO-C
  2043. Message-ID: <1518@islenet.UUCP>
  2044. Date: 23 Aug 85 04:25:54 GMT
  2045. Date-Received: 28 Aug 85 05:02:27 GMT
  2046. Distribution: net
  2047. Organization: Islenet Inc.,  Honolulu
  2048. Lines: 9
  2049.  
  2050. --MORE--(66%)Just discovered that there does not seem to be a sizeof() function
  2051. in Hippo C level I or II.  This would sure be useful for passing
  2052. the number of elements to an array sorting function like
  2053. sort(arrayname,sizeof(array[])/sizeof(array[element0]))
  2054.  
  2055. Thanks in advance for any comments/ideas.
  2056.  
  2057. j fields
  2058. ...!ihnp4!islenet!jayf
  2059. (Mail) End of article 4894 (of 4956)--what next? [npq] 
  2060.  
  2061. Article 4895 (61 more) in net.lang.c:
  2062. From: elric@proper.UUCP (elric)
  2063. Subject: Help
  2064. Message-ID: <248@proper.UUCP>
  2065. Date: 25 Aug 85 01:02:50 GMT
  2066. Date-Received: 28 Aug 85 05:03:20 GMT
  2067. Reply-To: elric@proper.UUCP (Elric of Imrryr)
  2068. Organization: Lunatic Laboratories Unltd.
  2069. Lines: 13
  2070.  
  2071. --MORE--(61%)
  2072.  
  2073.  When ever I attempt to compile the Fahrenheit-Celsius table program (on pg
  2074.  8 of _The C Programming Language_) I
  2075.  get this error:
  2076.         "temp.c", line 8: warning: old-fashioned initialization: use =
  2077.  
  2078. The line of code is:
  2079.                 lower = 0;  /* lower limit of temperature */
  2080.  
  2081.  Could someone tell me what I'm doing wrong?
  2082.     Thanx
  2083.      Elric of Imrryr
  2084. (Mail) End of article 4895 (of 4956)--what next? [npq] 
  2085.  
  2086. Article 4896 (60 more) in net.lang.c:
  2087. From: gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>)
  2088. Subject: Re: Help
  2089. Message-ID: <965@brl-tgr.ARPA>
  2090. Date: 26 Aug 85 01:55:13 GMT
  2091. Date-Received: 28 Aug 85 05:27:23 GMT
  2092. References: <248@proper.UUCP>
  2093. Organization: Ballistic Research Lab
  2094. Lines: 15
  2095.  
  2096. --MORE--(48%)>  When ever I attempt to compile the Fahrenheit-Celsius table program (on pg
  2097. >  8 of _The C Programming Language_) I
  2098. >  get this error:
  2099. >       "temp.c", line 8: warning: old-fashioned initialization: use =
  2100. > The line of code is:
  2101. >               lower = 0;  /* lower limit of temperature */
  2102. >  Could someone tell me what I'm doing wrong?
  2103.  
  2104. No, because you didn't supply enough information.
  2105. The program in the book is okay, so the error must be
  2106. in your code.  Check the line or two above where the
  2107. compiler detects the problem.  Especially check for
  2108. extra/missing { } /* */ ;
  2109. (Mail) End of article 4896 (of 4956)--what next? [npq] 
  2110.  
  2111. Article 4897 (59 more) in net.lang.c:
  2112. From: peters@cubsvax.UUCP (Peter S. Shenkin)
  2113. Newsgroups: net.lang.c,net.unix-wizards
  2114. Subject: Re: how has C bitten you?
  2115. Message-ID: <356@cubsvax.UUCP>
  2116. Date: 26 Aug 85 13:24:49 GMT
  2117. Date-Received: 28 Aug 85 06:35:43 GMT
  2118. References: <302@brl-tgr.ARPA> <471@baylor.UUCP> <148@chinet.UUCP> <>
  2119. Reply-To: peters@cubsvax.UUCP (Peter S. Shenkin)
  2120. Organization: Columbia Univ Biology, New York City
  2121. Lines: 27
  2122. Summary: I've sometimes bitten myself with MACRO definitions... read on!
  2123.  
  2124. --MORE--(43%)I've had several bugs involving code hidden in macro definitions which have 
  2125. been very difficult to find.  One I recall offhand went something like this:
  2126.  
  2127. /* OPEN MOUTH *****************************************************************/#define Coords(I)       (complicated.structure.redirection[I].x, \
  2128.                          complicated.structure.redirection[I].y, \
  2129.                          complicated.structure.redirection[I].z   )
  2130. main()
  2131. {
  2132.         ...
  2133.         subr(Coords(i));  /* BITE */
  2134.         ...
  2135. }
  2136. /***************************************************************************/
  2137. subr(x,y,z)
  2138. float x,y,z;
  2139. {...}
  2140. /* SWALLOW ******************************************************************/
  2141.  
  2142. Problem is, when expanded, the call to subr looks like
  2143.         subr((exp1,exp2,exp3));
  2144. The comma operator is applied, and subr() gets only exp1 !!!  The interesting
  2145. thing is that if anyone had asked me, whether (something), ((something)),
  2146. and (((something))) mean the same in C, I would have said "Yes," without
  2147. thinking.  Obviously, I would have been wrong.
  2148.  
  2149. Peter S. Shenkin        philabs!cubsvax!peters          Columbia Univ. Biology
  2150. (Mail) End of article 4897 (of 4956)--what next? [npq] 
  2151.  
  2152.  
  2153. Article 4900 (56 more) in net.lang.c:
  2154. From: DHowell.ES@Xerox.ARPA
  2155. Subject: Re: No Such Thing
  2156. Message-ID: <1008@brl-tgr.ARPA>
  2157. Date: 26 Aug 85 19:59:46 GMT
  2158. Date-Received: 28 Aug 85 06:36:48 GMT
  2159. Sender: news@brl-tgr.ARPA
  2160. Lines: 27
  2161.  
  2162. --MORE--(42%)> > ... when it comes to defining one's own
  2163. > > language extensions, this one seems like a winner:
  2164. > > 
  2165. > >     typedef int     bool;
  2166. > >     #define false   0
  2167. > >     #define true    1
  2168. > > 
  2169.  
  2170. > Seems like a loser to me. Just takes up space. I actually have to READ
  2171. it.
  2172.  
  2173. Not really.  You could usually safely assume that if someone is defining
  2174. true and false, he/she is defining it as above.  (if some joker decides
  2175. to define false as 29 and true as 53, he should be forced for eternity
  2176. to covert 10,000-line APL programs to Fortran! :-) )  I think it is much
  2177. easier to read things such as:
  2178.  
  2179.    done _ true;
  2180.  
  2181. than:
  2182.  
  2183.    done _ 1;
  2184.    
  2185. Of course, explanatory comments in any case improves readability even
  2186. more.
  2187.  
  2188. Dan
  2189. (Mail) End of article 4900 (of 4956)--what next? [npq] 
  2190.  
  2191. Article 4901 (55 more) in net.lang.c:
  2192. From: wcs@ho95e.UUCP (x0705)
  2193. Subject: Re: Help
  2194. Message-ID: <184@ho95e.UUCP>
  2195. Date: 26 Aug 85 15:47:33 GMT
  2196. Date-Received: 28 Aug 85 07:09:56 GMT
  2197. References: <248@proper.UUCP> <965@brl-tgr.ARPA>
  2198. Organization: AT&T Bell Labs, Holmdel NJ
  2199. Lines: 30
  2200.  
  2201. --MORE--(26%)> >  When ever I attempt to compile the Fahrenheit-Celsius table program (on pg
  2202. > >  8 of _The C Programming Language_) I
  2203. > >  get this error:
  2204. > >     "temp.c", line 8: warning: old-fashioned initialization: use =
  2205. > > 
  2206. > > The line of code is:
  2207. > >             lower = 0;  /* lower limit of temperature */
  2208. > > 
  2209. > >  Could someone tell me what I'm doing wrong?
  2210. > No, because you didn't supply enough information.
  2211. > The program in the book is okay, so the error must be
  2212. > in your code.  Check the line or two above where the
  2213. > compiler detects the problem.  Especially check for
  2214. > extra/missing { } /* */ ;
  2215.  
  2216. The error message you got is normally caused by using constructs that resemble
  2217. some of the "old-fashioned" language constructs.  For example:
  2218.         foo=-40;
  2219. used to mean foo -= 40, instead of foo = (-40).  Several generations of
  2220. compilers since then have code to reject "old-fashioned" constructs, even
  2221. though they're otherwise perfectly legal.
  2222.  
  2223. I this case, I'd check to make sure "lower" has been declared, as a scalar
  2224. (int or double?), and that you don't have any more variable declarations after
  2225. it.  (Since you can't mix decl.'s and executables, the compiler  may be trying
  2226. to get out of a bad situation, and guessing wrong about the error.  Also, as
  2227. Doug suggests, watch for extra/missing delimiters.
  2228. -- 
  2229. ## Bill Stewart, AT&T Bell Labs, Holmdel NJ 1-201-949-0705 ihnp4!ho95c!wcs
  2230. (Mail) End of article 4901 (of 4956)--what next? [npq] 
  2231.  
  2232. Article 4902 (54 more) in net.lang.c:
  2233. From: arnold@gatech.CSNET (Arnold Robbins)
  2234. Subject: Re: Cryptic C (YES/NO vs. TRUE/FALSE + other thoughts)
  2235. Message-ID: <989@gatech.CSNET>
  2236. Date: 23 Aug 85 16:57:20 GMT
  2237. Date-Received: 28 Aug 85 07:59:39 GMT
  2238. References: <2913@ncsu.UUCP>, <709@brl-tgr.ARPA> <5884@utzoo.UUCP>
  2239. Organization: Pr1mebusters!
  2240. Lines: 67
  2241. Summary: some thoughts on coding style for binary symbolic values
  2242.  
  2243. --MORE--(25%)In article <5884@utzoo.UUCP>, henry@utzoo.UUCP (Henry Spencer) writes:
  2244. > >     typedef int     bool;
  2245. > >     #define false   0
  2246. > >     #define true    1
  2247. > It's interesting to note that Kernighan&Plauger use "yes" and "no" rather
  2248. > than "true" and "false", and my own reaction is that the code often reads
  2249. > better that way.  Now that's something to *really* start a raging debate
  2250. > about... :-)
  2251. > -- 
  2252. >                               Henry Spencer @ U of Toronto Zoology
  2253.  
  2254. Well, this can get carried too far.  I have worked with code based on
  2255. Software Tools stuff that looks like
  2256.  
  2257.         dowrite (file, YES, NO, NO, YES);
  2258.  
  2259. Now, can you tell what the heck it is doing? Especially when the code for
  2260. dowrite() is 700 lines down in another file? I've often thought that a style
  2261. like
  2262.  
  2263. #define FORCEWRITE      1
  2264. #define NOFORCE         0
  2265.  
  2266. #define APPEND          1
  2267. #define NOAPPEND        0
  2268.  
  2269.         dowrite (file, FORCEWRITE, APPEND, ....);       /* call */
  2270.  
  2271. int dowrite (file, force, append,...)   /* actual procedure */
  2272. ...
  2273. {
  2274.         if (force)
  2275.                 ....
  2276.         if (append)
  2277.                 ....
  2278. }
  2279.  
  2280. is much clearer than the first style.  This is the kind of thing, if anything,
  2281. that "enums" would be most useful for (no flames about how poorly enums are
  2282. implemented. I'm talking conceptually here.).  Overall, TRUE or FALSE or YES
  2283. or NO doesn't make much difference to me.  However, I much prefer the following
  2284.  
  2285.         if (boolean)
  2286.                 something
  2287. and
  2288.  
  2289.         boolean = (x && y || c >= d);
  2290.  
  2291. to the overly verbose
  2292.  
  2293.         if (boolean == TRUE)
  2294.                 something
  2295.  
  2296.         if (x && y || c >= d)
  2297.                 boolean = TRUE;
  2298.         else
  2299.                 boolean = FALSE;
  2300.  
  2301. Now *that* should start a really raging debate! :-)
  2302. -- 
  2303. Arnold Robbins
  2304. CSNET:  arnold@gatech   ARPA:   arnold%gatech.csnet@csnet-relay.arpa
  2305. UUCP:   { akgua, allegra, hplabs, ihnp4, seismo, ut-sally }!gatech!arnold
  2306.  
  2307. Hello. You have reached the Coalition to Eliminate Answering Machines.
  2308. Unfortunately, no one can come to the phone right now....
  2309. (Mail) End of article 4902 (of 4956)--what next? [npq] 
  2310.  
  2311. Article 4903 (53 more) in net.lang.c:
  2312. From: peter@baylor.UUCP (Peter da Silva)
  2313. Subject: Re: Re:  Assignment in Conditionals
  2314. Message-ID: <499@baylor.UUCP>
  2315. Date: 21 Aug 85 16:12:55 GMT
  2316. Date-Received: 28 Aug 85 08:21:36 GMT
  2317. References: <594@brl-tgr.ARPA> <1214@ubc-cs.UUCP>
  2318. Organization: The Power Elite, Houston, TX
  2319. Lines: 21
  2320.  
  2321. --MORE--(36%)> A while back, I read a paper from the University of Toronto which
  2322. > tested two otherwise "identical" languages - one was expression
  2323. > oriented and one statement oriented.  Conclusion: the statement
  2324. > oriented one was easier to learn and programming was faster in it.
  2325. > The only problem was that the authors weren't sure how much of
  2326. > this effect was caused by most other programming languages being
  2327. > statement oriented (sorry, I don't have a reference for this -
  2328. > it was a CSRG report from U of T).
  2329.  
  2330. I think I saw that. It was in CACM or some similar journal... just ran
  2331. through my back copies but didn't find it, so either it's not a straight
  2332. article, it has a funny title, or I lent it to someone.
  2333.  
  2334. That wasn't the only flaw. The other problem was that the two languages
  2335. *weren't* otherwise identical, because if they were the statement
  2336. oriented one would have been a subset of the expression oriented
  2337. one.
  2338. -- 
  2339.         Peter (Made in Australia) da Silva
  2340.                 UUCP: ...!shell!neuro1!{hyd-ptd,baylor,datafac}!peter
  2341.                 MCI: PDASILVA; CIS: 70216,1076
  2342. (Mail) End of article 4903 (of 4956)--what next? [npq] 
  2343.  
  2344. Article 4904 (52 more) in net.lang.c:
  2345. From: rlk@chinet.UUCP (Richard L. Klappal)
  2346. Subject: Re: C bites Dog! / project proposal
  2347. Message-ID: <159@chinet.UUCP>
  2348. Date: 27 Aug 85 17:27:52 GMT
  2349. Date-Received: 29 Aug 85 00:32:37 GMT
  2350. References: <872@brl-tgr.ARPA> <2968@sdcc3.UUCP>
  2351. Reply-To: rlk@chinet.UUCP (Richard L. Klappal)
  2352. Organization: chinet, Public Access UN*X, Chicago
  2353. Lines: 43
  2354. Keywords: language proposal
  2355. Summary: 
  2356.  
  2357. --MORE--(27%)In article <2968@sdcc3.UUCP> ee161bep@sdcc3.UUCP (Paul Van de Graaf{|stu) writes:
  2358. >I'm ready for something beyond C, and I don't mean C++ or Ada.  If no one
  2359. >obliges all just have to do as Jim says and write my own.
  2360. >
  2361. >Paul van de Graaf      sdcsvax!sdcc3!ee161bep          U. C. San Diego
  2362.  
  2363. I have been feeling similarly.  Have been thinking of trying to write
  2364. something somewhere between C and PL/I.
  2365.  
  2366. 1)      Pointers are pointers, not pointers to ..
  2367.         (Loses pointer arith, has to be array addressing.  Use
  2368.         optimization to reduce common subexpressions to get rid of overhead.
  2369. 2)      More complete output format control.
  2370.         column(n) capability (like F77 Tn, or BASIC TAB(n))
  2371.  
  2372. 3)      string OPERATORS, not function calls.
  2373.  
  2374. 4)      discard ++/-- notation.
  2375.         keep +=, -=, /=, etc
  2376.  
  2377. 5)      then .. else .. end / do .. end / do n=1 to n [by nn] while (..)
  2378.  
  2379. 6)      no assignment in conditionals.
  2380.         means duplicating statements, but less confusion about
  2381.         .. is he assigning, or did he mean ==, and not catch it.
  2382.  
  2383. 7)      switch/case statement (or select ..when)
  2384.  
  2385. 8)      BASED / DEFINED data in stead of unions:  (They sill give me a
  2386.         headache.)
  2387. 10)     conversion functions instead of casts.  They get too unreadable
  2388.         too fast.
  2389.  
  2390. 11)     exception/condition handling ala PL/I.
  2391.  
  2392. 12)     no ternary operator (cond ? true : false)
  2393.  
  2394. 13)     I/O defined in the language. Not added as an afterthought like 
  2395.         Pascal/C/etc.  Will support both stream and record I/O.  Auto
  2396.         indexing (ISAM?/B-TREE?/??)) avail.
  2397. These are the general specs off the top of my head, and will probably
  2398. generate more flames than called for, but I personnaly prefer the
  2399. clarity of PL/I to the terseness of C.
  2400. (Mail) End of article 4904 (of 4956)--what next? [npq] 
  2401.  
  2402. Article 4905 (51 more) in net.lang.c:
  2403. From: chris@umcp-cs.UUCP (Chris Torek)
  2404. Subject: Re: How do I declare...
  2405. Message-ID: <1406@umcp-cs.UUCP>
  2406. Date: 27 Aug 85 10:50:13 GMT
  2407. Date-Received: 29 Aug 85 00:45:45 GMT
  2408. References: <368@persci.UUCP> <159@rtp47.UUCP>
  2409. Organization: U of Maryland, Computer Science Dept., College Park, MD
  2410. Lines: 37
  2411.  
  2412. --MORE--(31%)It is interesting to note that recursive type definitions make
  2413. sense only for function pointers, and only because they have side
  2414. effects.  Defining (a pointer to)+ makes no sense, because you can
  2415. never do anything with it.  It only points.  You can do an infinite
  2416. number of indirections and it still just points.
  2417.  
  2418. With function pointers, however, indirecting through them causes
  2419. side effects; one such effect can be "terminate this program",
  2420. which is the magic clause that makes this useful.
  2421.  
  2422. Fascinating.
  2423.  
  2424. By the way, note that structure declarations such as
  2425.  
  2426.         struct foo {
  2427.                 struct foo *next;
  2428.                 ...
  2429.         };
  2430.  
  2431. are not really recursive.  The inner entity is a pointer to struct
  2432. foo, not a struct foo.
  2433.  
  2434. Also by the way, the "most portable" declaration for (function
  2435. returning pointer to)+ is probably
  2436.  
  2437.         <type> *(*(*foo())())()
  2438.  
  2439. as this forces the function to return a pointer to a function that
  2440. returns a pointer; even if pointers to basic types are of different
  2441. sizes, most any compiler will have pointers to "pointer to function
  2442. returning pointer to <type>" being the same size as pointers to
  2443. "pointer to function returning pointer to function returning pointer
  2444. to <type>" and so forth.
  2445. -- 
  2446. In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
  2447. UUCP:   seismo!umcp-cs!chris
  2448. CSNet:  chris@umcp-cs           ARPA:   chris@maryland
  2449. (Mail) End of article 4905 (of 4956)--what next? [npq] 
  2450.  
  2451. Article 4906 (50 more) in net.lang.c:
  2452. From: throopw@rtp47.UUCP (Wayne Throop)
  2453. Subject: Re: Cryptic C (YES/NO vs. TRUE/FALSE + other thoughts)
  2454. Message-ID: <161@rtp47.UUCP>
  2455. Date: 26 Aug 85 19:26:23 GMT
  2456. Date-Received: 29 Aug 85 01:36:59 GMT
  2457. References: <2913@ncsu.UUCP>, <709@brl-tgr.ARPA> <5884@utzoo.UUCP> <989@gatech.CSNET>
  2458. Organization: Data General, RTP, NC
  2459. Lines: 28
  2460.  
  2461. --MORE--(39%)In message 989@gatech, Arnold Robbins gives an interesting example:
  2462.  
  2463. > #define FORCEWRITE    1
  2464. > #define NOFORCE               0
  2465. >
  2466. > #define APPEND                1
  2467. > #define NOAPPEND      0
  2468. >
  2469. >       dowrite (file, FORCEWRITE, APPEND, ....);       /* call */
  2470. >
  2471. > int dowrite (file, force, append,...) /* actual procedure */
  2472.  
  2473. I like this notion in general, but I point out a problem with it that a
  2474. (currently nonexistant) lint-like tool could help with.  What if the
  2475. call was done like so:
  2476.  
  2477.     dowrite( file, NOAPPEND, FORCEWRITE, ... );
  2478.  
  2479. This doesn't do remotely what you intend, and it very hard to detect.
  2480. What you "really want" is to be able to declare two enumerations, and
  2481. make lint check that you don't pass members of one enumeration to a
  2482. formal of another type.
  2483.  
  2484. Also, the "extra checking" that K&R says that lint-like tools are free
  2485. to do with typedefs would be welcome.  No current link (that I am aware
  2486. of) will allow using typedef as a type abstraction device.
  2487. -- 
  2488. Wayne Throop at Data General, RTP, NC
  2489. <the-known-world>!mcnc!rti-sel!rtp47!throopw
  2490. (Mail) End of article 4906 (of 4956)--what next? [npq] 
  2491.  
  2492. Article 4907 (49 more) in net.lang.c:
  2493. From: mab@druca.UUCP (BlandMA)
  2494. Subject: Re: how has C bitten you?
  2495. Message-ID: <956@druca.UUCP>
  2496. Date: 28 Aug 85 19:18:18 GMT
  2497. Date-Received: 30 Aug 85 01:36:24 GMT
  2498. References: <302@brl-tgr.ARPA> <471@baylor.UUCP> <148@chinet.UUCP> <> <356@cubsvax.UUCP>
  2499. Organization: AT&T Information Systems Laboratories, Denver
  2500. Lines: 7
  2501.  
  2502. --MORE--(75%)I was amused when I realized why this statement didn't print anything:
  2503.  
  2504.         printf("toggle ">" verbosity\n");
  2505.  
  2506. -- 
  2507. Alan Bland     {ihnp4|allegra}!druca!mab
  2508. AT&T Information Systems, Denver CO
  2509. (Mail) End of article 4907 (of 4956)--what next? [npq] 
  2510.  
  2511. Article 4908 (48 more) in net.lang.c:
  2512. From: rcj@burl.UUCP (Curtis Jackson)
  2513. Newsgroups: net.bugs.usg,net.lang.c,net.unix-wizards
  2514. Subject: SVR2 (at least) printf bug
  2515. Message-ID: <836@burl.UUCP>
  2516. Date: 28 Aug 85 19:42:51 GMT
  2517. Date-Received: 30 Aug 85 01:51:39 GMT
  2518. Reply-To: rcj@burl.UUCP (Curtis Jackson)
  2519. Organization: AT&T Technologies, Burlington NC
  2520. Lines: 40
  2521.  
  2522. --MORE--(27%)This bug is known to the Unix Hotline and the appropriate PIC (People
  2523. In Charge), but wasn't known to me so I thought I'd share it.
  2524.  
  2525. If you open a file for simple update (mode "r+" on fopen), then read
  2526. some stuff in the file, then try to write on the file, the writes
  2527. will appear to work perfectly (printf returns good bytecounts and
  2528. everything), but no writes will take place in the real world.
  2529.  
  2530. This happens because the code to check for _IORW (read/write permissions)
  2531. is wrong in printf.c, fprintf.c, vprintf.c, and vfprintf.c.  This
  2532. causes the write permissions (_IOWRT) turnon code to be skipped and
  2533. _doprnt() returns a negative number; so the _cnt field in the FILE
  2534. descriptor decrements rather than increments, and the fflush() therefore
  2535. has no effect -- thus silently no writes.
  2536.  
  2537. The errant lines are:
  2538.  
  2539.         if (!(stdout->_flag | _IOWRT)) {
  2540.                 /* if no write flag */
  2541.                 if (stdout->_flag | _IORW) {
  2542.  
  2543. since |'ing with a constant is not a very good idea, change them to &'s:
  2544.  
  2545.         if (!(stdout->_flag & _IOWRT)) {
  2546.                 /* if no write flag */
  2547.                 if (stdout->_flag & _IORW) {
  2548.  
  2549. and everything works fine.
  2550.  
  2551. I found this bug very interesting to track down since (apparently) the
  2552. initial modes on the file are both _IOWRT and _IORW.  This means that
  2553. if you just write a file fopened with "r+" everything works, but the
  2554. first read turns off _IOWRT and any subsequent writes silently fail.
  2555.  
  2556. Don't forget to remake the library!!
  2557. -- 
  2558.  
  2559. The MAD Programmer -- 919-228-3313 (Cornet 291)
  2560. alias: Curtis Jackson   ...![ ihnp4 ulysses cbosgd mgnetp ]!burl!rcj
  2561.                         ...![ ihnp4 cbosgd akgua masscomp ]!clyde!rcj
  2562. (Mail) End of article 4908 (of 4956)--what next? [npq] 
  2563.  
  2564. Article 4909 (47 more) in net.lang.c:
  2565. From: garys@bunker.UUCP (Gary M. Samuelson)
  2566. Subject: Re: Re: C bites (Null loop-bodies)
  2567. Message-ID: <958@bunker.UUCP>
  2568. Date: 27 Aug 85 15:26:09 GMT
  2569. Date-Received: 30 Aug 85 02:12:01 GMT
  2570. References: <165@3comvax.UUCP> <418@phri.UUCP>
  2571. Distribution: net
  2572. Organization: Bunker Ramo, Trumbull Ct
  2573. Lines: 16
  2574.  
  2575. --MORE--(64%)>       I put null loop-bodies on a separate line like in the following
  2576. > example.
  2577. >               while (eatup() != '\n')
  2578. >                       ;
  2579.  
  2580. Putting the semi-colon on a separate line does help make it clear
  2581. that the body of the loop is intentionally null, but what I like
  2582. even better is:
  2583.  
  2584.                 while( eatup() != '\n' )
  2585.                         continue;
  2586.  
  2587. Comments?
  2588.  
  2589. Gary Samuelson
  2590. (Mail) End of article 4909 (of 4956)--what next? [npq] 
  2591.  
  2592. Article 4910 (46 more) in net.lang.c:
  2593. From: joemu@nsc-pdc.UUCP (Joe Mueller)
  2594. Subject: Re: Re: How do I declare...
  2595. Message-ID: <476@nsc-pdc.UUCP>
  2596. Date: 26 Aug 85 23:46:18 GMT
  2597. Date-Received: 30 Aug 85 02:18:21 GMT
  2598. References: <368@persci.UUCP> <159@rtp47.UUCP>
  2599. Organization: NSC Portland Development Center, Portland Oregon
  2600. Lines: 23
  2601.  
  2602. --MORE--(33%)> Thus, if you want an array of pointers to arrays of pointers, you can't
  2603. > do it.  Nor can you declare functions returning pointers to functions.
  2604.  
  2605. You have to be kidding, you can declare both of these things although the
  2606. syntax may be a little weird.
  2607.  
  2608. Here's an array of 5 pointers to arrays of 6 pointers to char
  2609.         char *(*foo[5])[6]      /* how do you like that sports fans! */
  2610.  
  2611. Here's a function returning a pointer to a function returning an int
  2612.         int (*foo())()
  2613.  
  2614. If you have trouble declaring things or deciphering existing code, I highly
  2615. recommend a utility called "cdecl". It takes an english description of what
  2616. you want and gives you the C syntax for it, it will also take a C declaration
  2617. and translate it to an english description of what it is. I used it on the
  2618. above examples so I got the declaration right the first time with minimal fuss.
  2619. It has been posted to the net at least once before, if you absolutely can't
  2620. find it elsewhere and you want a copy, I'll send it to you. If too many people
  2621. need it, I'll post it to the net.
  2622.  
  2623. The language has hooks to declare incredibly complex data structures, if your
  2624. compiler can't hack it, it's not the language's fault.
  2625. (Mail) End of article 4910 (of 4956)--what next? [npq] 
  2626.  
  2627. Article 4911 (45 more) in net.lang.c:
  2628. From: reg@vaxine.UUCP (Rick Genter)
  2629. Subject: How to declare a pointer to function returning pointer to function
  2630. Message-ID: <630@vaxine.UUCP>
  2631. Date: 27 Aug 85 13:35:42 GMT
  2632. Date-Received: 30 Aug 85 02:38:39 GMT
  2633. Organization: Automatix, Inc., Billerica, MA
  2634. Lines: 23
  2635.  
  2636. --MORE--(44%)
  2637.      I couldn't resist trying this.  Cdecl claims no problem declaring
  2638. something to be a pointer to a function returning a pointer to a function
  2639. returning int:
  2640.  
  2641. Script started on Tue Aug 27 09:27:43 1985
  2642.  
  2643. % cdecl
  2644. declare x as pointer to function returning pointer to function returning int
  2645. int (*(*x)())()
  2646. %
  2647.  
  2648. Script done on Tue Aug 27 09:28:32 1985
  2649.  
  2650.      No, that's not lisp ... :-)
  2651.  
  2652.                                         - reg
  2653.                                         Rick Genter
  2654.                                         Automatix Inc.
  2655.                                         ...!decvax!encore!vaxine!reg
  2656.  
  2657. (Note: As of next week (9/3/85) I will be at BBN Labs.  I don't know what my
  2658.        new electronic address will be).
  2659. (Mail) End of article 4911 (of 4956)--what next? [npq] 
  2660.  
  2661. Article 4912 (44 more) in net.lang.c:
  2662. From: ben@cernvax.UUCP (ben)
  2663. Subject: Xinu Applications: any experience??
  2664. Message-ID: <217@cernvax.UUCP>
  2665. Date: 27 Aug 85 16:38:14 GMT
  2666. Date-Received: 30 Aug 85 02:47:45 GMT
  2667. Organization: CERN, Geneva/Switzerland
  2668. Lines: 8
  2669.  
  2670. --MORE--(66%)
  2671.   Does anyone out there have experience of making PRACTICAL
  2672. applications using Douglas Comer's Xinu system?  We are
  2673. interested particularly in any real-time applications for
  2674. 68000's.
  2675.  
  2676.    Ben M. Segal,  CERN-DD,  1211 Geneva 23,  Switzerland
  2677.                   (ben@cernvax via mcvax)
  2678. (Mail) End of article 4912 (of 4956)--what next? [npq] 
  2679.  
  2680. Article 4913 (43 more) in net.lang.c:
  2681. From: debe@mit-vax.UUCP (Stephen Humble)
  2682. Subject: Re: Help
  2683. Message-ID: <725@mit-vax.UUCP>
  2684. Date: 28 Aug 85 18:09:48 GMT
  2685. Date-Received: 30 Aug 85 03:44:30 GMT
  2686. References: <248@proper.UUCP>
  2687. Reply-To: debe@mit-vax.UUCP (Stephen Humble)
  2688. Organization: MIT, Cambridge, MA
  2689. Lines: 15
  2690. Summary: hyphen in function name?
  2691.  
  2692. --MORE--(57%)Sender:
  2693.  
  2694. [DO THE RIGHT THING]
  2695.  
  2696. >       "temp.c", line 8: warning: old-fashioned initialization: use =
  2697.  
  2698. This has happened to me too, and it's usually because I put a hyphen
  2699. in the function's name, so cc thinks I want to subtract one part of
  2700. the name from the other part, or something equally absurd. Hyphens in
  2701. declarators are a no_no. :-)
  2702. cc is notorious for not telling you that an error has occurred until
  2703. several lines after the actual error.
  2704. (Mail) End of article 4913 (of 4956)--what next? [npq] 
  2705.  
  2706. Article 4914 (42 more) in net.lang.c:
  2707. From: driehuis%hlerul5.BITNET@Berkeley
  2708. Subject: Re: Re: Re: C bites (Null loop-bodies)
  2709. Message-ID: <1066@brl-tgr.ARPA>
  2710. Date: 28 Aug 85 18:22:45 GMT
  2711. Date-Received: 31 Aug 85 02:11:51 GMT
  2712. Sender: news@brl-tgr.ARPA
  2713. Lines: 31
  2714.  
  2715. --MORE--(32%)Gary M. Samuelson <garys@bunker.uucp> writes:
  2716. >>     I put null loop-bodies on a separate line like in the following
  2717. >> example.
  2718. >>
  2719. >>         while (eatup() != '\n')
  2720. >>             ;
  2721. >
  2722. >Putting the semi-colon on a separate line does help make it clear
  2723. >that the body of the loop is intentionally null, but what I like
  2724. >even better is:
  2725. >
  2726. >        while( eatup() != '\n' )
  2727. >            continue;
  2728. >
  2729. >Comments?
  2730. Yes. I am not fond of using continue if it is not necessary
  2731. to do so. All loop-modyfying statements require an additional
  2732. effort to read - at least, for me.
  2733. Neither do I like the suggesion I saw in info-c, that read
  2734. something like
  2735. >        while (function() != READY) {
  2736. >             }
  2737. The reason why is quite prosaic: when I edit an existing
  2738. file into something else, with cutting, pasting, and deleting,
  2739. sometimes (no more than once a week :=)) a line or even a
  2740. block of text gets lost, leaving embraced white space.
  2741. My first reaction to seeing braces, embracing nothing, is: oops...
  2742. been too hastily with the delete-line key.
  2743. The convention to use a period on a line by itself is
  2744. sufficient to recognise at first sight: "this is a null
  2745. statement".
  2746. (Mail) End of article 4914 (of 4956)--what next? [npq] 
  2747.  
  2748. Article 4915 (41 more) in net.lang.c:
  2749. From: chris@umcp-cs.UUCP (Chris Torek)
  2750. Subject: Re: Help
  2751. Message-ID: <1420@umcp-cs.UUCP>
  2752. Date: 28 Aug 85 15:16:49 GMT
  2753. Date-Received: 31 Aug 85 02:13:19 GMT
  2754. References: <248@proper.UUCP> <965@brl-tgr.ARPA> <184@ho95e.UUCP>
  2755. Organization: U of Maryland, Computer Science Dept., College Park, MD
  2756. Lines: 36
  2757.  
  2758. --MORE--(34%)> > > When ever I attempt to compile the Fahrenheit-Celsius table
  2759. > > > program (on pg 8 of _The C Programming Language_) I get this error:
  2760. > > >   "temp.c", line 8: warning: old-fashioned initialization: use =
  2761.  
  2762. > The error message you got is normally caused by using constructs
  2763. > that resemble some of the "old-fashioned" language constructs.
  2764.  
  2765. Right so far...
  2766.  
  2767. > For example:
  2768. >       foo=-40;
  2769. > used to mean foo -= 40, instead of foo = (-40).
  2770.  
  2771. This is true, but not directly related to the actual error given above.
  2772.  
  2773. > I this case, I'd check to make sure "lower" has been declared, as
  2774. > a scalar (int or double?), and that you don't have any more variable
  2775. > declarations after it.
  2776.  
  2777. The problem is one of two things.  The Portable C Compiler has seen
  2778. either
  2779.  
  2780.         <type> <variable> <constant>
  2781.  
  2782. or
  2783.  
  2784.         <type> <variable> {
  2785.  
  2786. when it gives the "warning: old-fashioned initialization: use ="
  2787. error message.  (The next message may well be "syntax error".)
  2788. One of the rather neat things you can do is run "cc -E" on the
  2789. source file, to see what's actually being compiled.
  2790. -- 
  2791. In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
  2792. UUCP:   seismo!umcp-cs!chris
  2793. CSNet:  chris@umcp-cs           ARPA:   chris@maryland
  2794. (Mail) End of article 4915 (of 4956)--what next? [npq] 
  2795.  
  2796. Article 4916 (40 more) in net.lang.c:
  2797. From: chris@umcp-cs.UUCP (Chris Torek)
  2798. Subject: Re: How to declare a pointer to function returning pointer to function
  2799. Message-ID: <1421@umcp-cs.UUCP>
  2800. Date: 28 Aug 85 15:19:44 GMT
  2801. Date-Received: 31 Aug 85 02:13:27 GMT
  2802. References: <630@vaxine.UUCP>
  2803. Organization: U of Maryland, Computer Science Dept., College Park, MD
  2804. Lines: 12
  2805.  
  2806. --MORE--(55%)> I couldn't resist trying this.  Cdecl claims no problem declaring
  2807. > something to be a pointer to a function returning a pointer to a
  2808. > function returning int:
  2809.  
  2810. There *is* no problem declaring that.  The problem is declaring a
  2811. function returning a pointer to a function returning a pointer to
  2812. a function returning a pointer to a ..., ad infinitum.  *There is
  2813. no base type in the definition*.
  2814. -- 
  2815. In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
  2816. UUCP:   seismo!umcp-cs!chris
  2817. CSNet:  chris@umcp-cs           ARPA:   chris@maryland
  2818. (Mail) End of article 4916 (of 4956)--what next? [npq] 
  2819.  
  2820. Article 4917 (39 more) in net.lang.c:
  2821. From: arnold@ucsfcgl.UUCP (Ken Arnold%CGL)
  2822. Subject: Re: C bites Dog!
  2823. Message-ID: <625@ucsfcgl.UUCP>
  2824. Date: 28 Aug 85 19:11:11 GMT
  2825. Date-Received: 31 Aug 85 02:40:47 GMT
  2826. References: <872@brl-tgr.ARPA> <2968@sdcc3.UUCP>
  2827. Reply-To: arnold@ucsfcgl.UUCP (Ken Arnold)
  2828. Organization: UCSF Computer Graphics Lab
  2829. Lines: 31
  2830.  
  2831. --MORE--(30%)In article <2968@sdcc3.UUCP> ee161bep@sdcc3.UUCP (Paul Van de Graaf) writes:
  2832. >Action also has the if <> then <> fi style bracketing which I suppose was
  2833. >inspired by the Bourne shell.  I personally don't like the case .. esac stuff
  2834. >in the Bourne shell, but I can't understand why C programmers are so concerned
  2835. >about typing 2 to 5 letter keywords instead of (, ), {, and }.  I don't type
  2836. >special characters very well, and I think it's because of having to hit that
  2837. ><shift> key.
  2838.  
  2839. To me it is not a question of typing, but a question of bandwidth.
  2840. Keywords look a lot like variables unless read, whereas symbols don't
  2841. look like variables at all.  The extreme examples are something like
  2842.  
  2843.         add a to b and assign to c
  2844.  
  2845.                 vs.
  2846.  
  2847.         c = a + b
  2848.  
  2849. where the second is clearly more legible.  This can be taken to
  2850. extremes, of course, but I still find that it is easier to scan a
  2851. language which uses a reasonably rich token set instead of a lot of
  2852. keywords.  Once you learn such a set of symbols, it seems easier to
  2853. read quickly, probably because the bandwitdh of communication is
  2854. higher, and operators are quickly visible as operators, as distinct
  2855. from programmer-defined tokens.
  2856.  
  2857. How easy a language is to type seems relatively unimportant compared to
  2858. other factors, including legibility.  APL is reasonably easy to
  2859. *type*...
  2860.  
  2861.                 Ken Arnold
  2862. (Mail) End of article 4917 (of 4956)--what next? [npq] 
  2863.  
  2864. Article 4918 (38 more) in net.lang.c:
  2865. From: scott@othervax.UUCP (Scott Pace)
  2866. Subject: Re: How do I declare...
  2867. Message-ID: <690@othervax.UUCP>
  2868. Date: 27 Aug 85 18:39:58 GMT
  2869. Date-Received: 31 Aug 85 03:38:08 GMT
  2870. References: <368@persci.UUCP> <159@rtp47.UUCP>
  2871. Reply-To: scott@othervax.UUCP (Scott Pace)
  2872. Organization: Philips Information Systems - St. Laurent  P.Q., Canada
  2873. Lines: 49
  2874.  
  2875. --MORE--(34%)>> Either I'm missing the perfectly obvious or I've found something
  2876. >> that's impossible to declare in C, even though it makes sense.
  2877.  
  2878. >You have discovered a fundamental flaw in C type notation.  In essence,
  2879. >C allows recursive types only in structs, unions, and enums (and I'm not
  2880. >sure how it would be usefull in enums, so that one can be ruled out for
  2881. >practical purposes).
  2882. >
  2883. >Thus, if you want an array of pointers to arrays of pointers, you can't
  2884. >do it.  Nor can you declare functions returning pointers to functions.
  2885.  
  2886.  
  2887. Well, our compiler seems to handle these sort of constructs ok:-
  2888.  
  2889. looking at an array of pointers to arrays of pointers first...
  2890.  
  2891. int *(*foo1[10])[];
  2892.  
  2893. here foo1 is an array of pointers, each pointer pointing to an array
  2894. of pointers to int's.
  2895. Thus an integer element might be accessed as follows:
  2896.  
  2897. *(*foo1[1])[2] and another way might be **foo1[0]
  2898.  
  2899.  
  2900. now looking at functions returning pointers to functions:-
  2901.  
  2902. int *(*func1())();
  2903.  
  2904. here func is a function returning a pointer to a function, and this
  2905. function returns a pointer to an int.
  2906. Thus you could do things like:
  2907.  
  2908. int *(*func2)(); /*pointer to a function returning a pointer to int*/
  2909. int *x;
  2910. .
  2911. .
  2912. .
  2913. func2 = func1();
  2914. x = (func2)();
  2915. .
  2916. .
  2917. etc.
  2918.  
  2919. Cheers
  2920.  
  2921.         Scott Pace, ...!philabs!micomvax!othervax!scott
  2922.  
  2923. (I hope I got all that right!!!)
  2924. (Mail) End of article 4918 (of 4956)--what next? [npq] 
  2925.  
  2926. Article 4920 (36 more) in net.lang.c:
  2927. From: tim@callan.UUCP (Tim Smith)
  2928. Newsgroups: net.lang.c,net.micro.mac
  2929. Subject: Re: help with sizeof() in HIPPO-C
  2930. Message-ID: <1088@callan.UUCP>
  2931. Date: 27 Aug 85 00:22:46 GMT
  2932. Date-Received: 31 Aug 85 06:00:52 GMT
  2933. References: <1518@islenet.UUCP>
  2934. Distribution: net
  2935. Organization: Callan Data Systems, Westlake Village, CA
  2936. Lines: 27
  2937.  
  2938. --MORE--(41%)> Just discovered that there does not seem to be a sizeof() function
  2939. > in Hippo C level I or II.  This would sure be useful for passing
  2940.  
  2941. Level I was written in Pasadena, and when I was bored, I would go over
  2942. and hassle them about things I thought they were doing wrong.  I don't think
  2943. I would have missed a lack of sizeof.  Also, we once ran a set of C progrs
  2944. meant to test out pcc through Hippo level I, and there must have been
  2945. a sizeof in there somewhere!  ( no - I can't tell anyone where to get
  2946. the set of test programs. ).
  2947.  
  2948. Anyway, try all of the following, since I am not sure how they handle
  2949. builtin functions like sizeof -- they may have fucked up the parsing:
  2950.  
  2951.         sizeof x ;              /* where x is a variable */
  2952.         sizeof(x) ;
  2953.         sizeof( x ) ;
  2954.         sizeof (x) ;
  2955.         sizeof ( x ) ;
  2956.         sizeof(int) ;
  2957.         sizeof( int ) ;
  2958.         sizeof (int) ;
  2959.         sizeof ( int ) ;
  2960.  
  2961. If none of these work, give them a call.
  2962. -- 
  2963.                                         Tim Smith
  2964.                                 ihnp4!{cithep,wlbr!callan}!tim
  2965. (Mail) End of article 4920 (of 4956)--what next? [npq] 
  2966.  
  2967.  
  2968. Article 4922 (34 more) in net.lang.c:
  2969. From: franka@mmintl.UUCP (Frank Adams)
  2970. Subject: Re: Cryptic C (YES/NO vs. TRUE/FALSE + other thoughts)
  2971. Message-ID: <625@mmintl.UUCP>
  2972. Date: 27 Aug 85 03:01:24 GMT
  2973. Date-Received: 31 Aug 85 09:52:38 GMT
  2974. References: <2913@ncsu.UUCP> <709@brl-tgr.ARPA> <5884@utzoo.UUCP> <989@gatech.CSNET>
  2975. Reply-To: franka@mmintl.UUCP (Frank Adams)
  2976. Organization: Multimate International, E. Hartford, CT
  2977. Lines: 33
  2978. Summary: Aggregates are even better
  2979.  
  2980. --MORE--(42%)
  2981. In article <989@gatech.CSNET> arnold@gatech.CSNET (Arnold Robbins) writes:
  2982. >
  2983. >Well, this can get carried too far.  I have worked with code based on
  2984. >Software Tools stuff that looks like
  2985. >
  2986. >       dowrite (file, YES, NO, NO, YES);
  2987. >
  2988. >Now, can you tell what the heck it is doing? Especially when the code for
  2989. >dowrite() is 700 lines down in another file? I've often thought that a style
  2990. >like
  2991. >
  2992. >#define FORCEWRITE     1
  2993. >#define NOFORCE                0
  2994. >
  2995. >#define APPEND         1
  2996. >#define NOAPPEND       0
  2997. >
  2998. >       dowrite (file, FORCEWRITE, APPEND, ....);       /* call */
  2999. >
  3000. >
  3001. >is much clearer than the first style.  This is the kind of thing, if anything,
  3002. >that "enums" would be most useful for (no flames about how poorly enums are
  3003. >implemented. I'm talking conceptually here.).
  3004.  
  3005. The problem with your solution is I can just easily write
  3006.  
  3007.         dowrite(file, APPEND, NOFORCE, ...)
  3008.  
  3009. and will have a terrible time finding the error.  This is where Ada wins:
  3010.  
  3011.         dowrite(file, append=>true, force=>false, ...)
  3012.  
  3013. is clear, simple, and error-resistant.
  3014. (Mail) End of article 4922 (of 4956)--what next? [npq] 
  3015.  
  3016. Article 4923 (33 more) in net.lang.c:
  3017. From: stern@bnl.UUCP (eric)
  3018. Subject: Re: VAX VMS C / UNIX C Compatibility -- Need Info
  3019. Message-ID: <150@bnl.UUCP>
  3020. Date: 27 Aug 85 16:50:32 GMT
  3021. Date-Received: 31 Aug 85 09:53:03 GMT
  3022. References: <488@rdin.UUCP> <249@watmum.UUCP> <545@osu-eddie.UUCP>
  3023. Organization: Brookhaven National Lab. Upton, N.Y.
  3024. Lines: 19
  3025.  
  3026. --MORE--(41%)> > VMS is very record-ish, while stream i/o is the unix thing. Unfortunately,
  3027. > > port didn't work because we didn't really spend the effort required to do
  3028. > > the QIO's required to fake stream i/o on VMS. 
  3029.  
  3030. A year or two ago, I wrote a xmodem protocol program for VMS and
  3031. UNIX in C.  The effort required to set up the raw state in both OS's
  3032. was equivalent.  Doing these things on VMS takes no more effort
  3033. than finding the appropriate ioctl function codes on UNIX.  When
  3034. it got to doing the reads byte by byte with timeouts, VMS was
  3035. much simpler than UNIX.  Under VMS, just one function call was
  3036. able to read n characters returning an error if more than t
  3037. seconds elapsed between characters.  Under UNIX, it was a complicated
  3038. mess with two functions, alarms, longjmps and extra buffering.
  3039.  
  3040.                                                 Eric G. Stern
  3041.                                                 stern@bnl.arpa
  3042.                                                 stern@bnl.bitnet
  3043.                                                 ...!philabs!sbcs!bnl!stern
  3044. (Mail) End of article 4923 (of 4956)--what next? [npq] 
  3045.  
  3046. Article 4924 (32 more) in net.lang.c:
  3047. From: throopw@rtp47.UUCP (Wayne Throop)
  3048. Subject: Re: How do I declare... (I knew that!)
  3049. Message-ID: <164@rtp47.UUCP>
  3050. Date: 29 Aug 85 17:20:55 GMT
  3051. Date-Received: 2 Sep 85 04:18:33 GMT
  3052. Organization: Data General, RTP, NC
  3053. Lines: 27
  3054.  
  3055. --MORE--(28%)I have been inundated with a flood of postings and mail saying "you
  3056. can so declare a pointer to a function returning a pointer to a
  3057. function".  I started replying by mail, but this proves impractical due
  3058. to volume.  Let me introduce my defense as I did in the first letter I
  3059. sent out:
  3060.  
  3061. "Aaaarrrrgggghhhh!"
  3062.  
  3063. There.  I feel better now.  I really *did know* that you can declare
  3064. pointers to arrays of pointers to arrays (of primitive types), and
  3065. pointers to functions returning pointers to functions (returning
  3066. primitive types).  I thought it was clear from the context that I meant
  3067. that it is impossible to declare a pointer to a function returning
  3068. pointer to function *of that function's own type*.  But noooooooo!  All
  3069. you nit-pickers assumed I meant what I said!  Sheeesh!   :-)
  3070.  
  3071. In any event, I still maintain that C's type notation is deficent, in
  3072. that it only allows recursion in declarations of structs, unions, and
  3073. enums (and I haven't found a use for recursion in enums).  It does *not*
  3074. allow recursion in type declaractions that contain only pointer,
  3075. function, or array constructs.
  3076.  
  3077. If you wish to show me the error of my ways, mail or post a typedef F
  3078. of a pointer-to-function-returning-type-F.  My claim is that C allows no
  3079. such constructs, and that this lack is a shortcoming of the C language.
  3080. -- 
  3081. Wayne Throop at Data General, RTP, NC
  3082. <the-known-world>!mcnc!rti-sel!rtp47!throopw
  3083. (Mail) End of article 4924 (of 4956)--what next? [npq] 
  3084.  
  3085. Article 4925 (31 more) in net.lang.c:
  3086. From: stew@harvard.ARPA (Stew Rubenstein)
  3087. Subject: Re: Cryptic C (YES/NO vs. TRUE/FALSE + other thoughts)
  3088. Message-ID: <327@harvard.ARPA>
  3089. Date: 31 Aug 85 02:12:58 GMT
  3090. Date-Received: 2 Sep 85 05:34:43 GMT
  3091. References: <2913@ncsu.UUCP> <709@brl-tgr.ARPA> <5884@utzoo.UUCP> <989@gatech.CSNET> <625@mmintl.UUCP>
  3092. Reply-To: stew@harvard.UUCP (Stew Rubenstein)
  3093. Organization: Aiken Computation Laboratory, Harvard
  3094. Lines: 32
  3095. Summary: 
  3096.  
  3097. --MORE--(36%)In article <625@mmintl.UUCP> franka@mmintl.UUCP (Frank Adams) writes:
  3098. >
  3099. >In article <989@gatech.CSNET> arnold@gatech.CSNET (Arnold Robbins) writes:
  3100. >
  3101. >  >Well, this can get carried too far.  I have worked with code based on
  3102. >  >Software Tools stuff that looks like
  3103. >  >
  3104. >  >    dowrite (file, YES, NO, NO, YES);
  3105. >...
  3106. >  >    dowrite (file, FORCEWRITE, APPEND, ....);       /* call */
  3107. >  >
  3108. >  >
  3109. >  >is much clearer than the first style.  This is the kind of thing, if
  3110. >  >anything, that "enums" would be most useful for (no flames about how poorly
  3111. >  >enums are implemented. I'm talking conceptually here.).
  3112. >
  3113. >The problem with your solution is I can just easily write
  3114. >
  3115. >       dowrite(file, APPEND, NOFORCE, ...)
  3116. >
  3117. >and will have a terrible time finding the error.  This is where Ada wins:
  3118. >
  3119. >       dowrite(file, append=>true, force=>false, ...)
  3120.  
  3121. In a perfect world, the argument types for dowrite() would be declared
  3122. as different enum types and the compiler will complain if you mix them
  3123. up (i.e. in new ANSI C if I understand it right).  In a slightly less
  3124. perfect world, lint would complain about the inconsistency.  We were
  3125. talking conceptually, right?  Not to say that the keyword style isn't
  3126. better, but this is one the compiler ought to catch.
  3127.  
  3128. Stew
  3129. (Mail) End of article 4925 (of 4956)--what next? [npq] 
  3130.  
  3131. Article 4926 (30 more) in net.lang.c:
  3132. From: mer@prism.UUCP
  3133. Subject: Re: Re: c programming style - READ THIS
  3134. Message-ID: <5400011@prism.UUCP>
  3135. Date: 28 Aug 85 19:12:00 GMT
  3136. Date-Received: 2 Sep 85 05:36:39 GMT
  3137. References: <90@rtp47.UUCP>
  3138. Lines: 9
  3139.  
  3140. --MORE--(54%)
  3141. Since 'p+n', where p is a pointer and n is an integer, is equivalent to
  3142. adding n*sizeof(whatever p points to), the safe and portable way of adding
  3143. an integer to a pointer treated as an integer is 
  3144.          (char *)p + n
  3145. since (I think) character are always a byte wide.  If that's not always the
  3146. case, I apologize; on the other hand, it's probably safe than converting
  3147. a pointer to an int or a long;  I had trouble porting something from a VAX
  3148. to a Pyramid because of a cast of this sort.
  3149. (Mail) End of article 4926 (of 4956)--what next? [npq] 
  3150.  
  3151. Article 4928 (28 more) in net.lang.c:
  3152. From: darryl@ISM780.UUCP
  3153. Subject: Re: What does the compiler think I am do
  3154. Message-ID: <30000011@ISM780.UUCP>
  3155. Date: 30 Aug 85 12:43:00 GMT
  3156. Date-Received: 2 Sep 85 05:37:23 GMT
  3157. References: <648@ihu1m.UUCP>
  3158. Lines: 15
  3159.  
  3160. --MORE--(46%)
  3161.  
  3162.  
  3163. There is no such thing as an "assignment statement" in C.  Rather, assignment
  3164. is just one more binary operator, and the language supports the "expression
  3165. statement".  What you have written, c - a;, is just another expression
  3166. statement, that merely has no side effects.  According to the Unix philosophy,
  3167. this is perfectly ok, and (if you have a PCC compiler) it probably generates
  3168. the code to load up the values and do the subtract (why? beacause you asked
  3169. it to).  Hence lint.  Lint will also warn you about using = in conditionals
  3170. where you might have meant ==.
  3171.  
  3172.             --Darryl Richman, INTERACTIVE Systems Corp.
  3173.             ...!cca!ima!ism780!darryl
  3174.             The views expressed above are my opinions only.
  3175. (Mail) End of article 4928 (of 4956)--what next? [npq] 
  3176.  
  3177. Article 4929 (27 more) in net.lang.c:
  3178. From: coltoff@burdvax.UUCP ( Joel Coltoff)
  3179. Subject: Re: Re: C bites (Null loop-bodies)
  3180. Message-ID: <2107@burdvax.UUCP>
  3181. Date: 30 Aug 85 14:55:30 GMT
  3182. Date-Received: 2 Sep 85 05:43:25 GMT
  3183. References: <958@bunker.UUCP>
  3184. Organization: System Development Corporation, Paoli PA
  3185. Lines: 10
  3186.  
  3187. --MORE--(73%)<<>>
  3188.  
  3189. My approach is to explicitly spell it out with a comment. Sometimes they
  3190. are the only comments in the program
  3191.  
  3192.         while ( eatup() != '\n' )
  3193.                 /* NULL BODY */;
  3194.  
  3195.         - Joel Coltoff
  3196.         {prseby,sdcrdcf,psuvax1}!burdvax!coltoff
  3197. (Mail) End of article 4929 (of 4956)--what next? [npq] 
  3198.  
  3199. Article 4930 (26 more) in net.lang.c:
  3200. From: peter@graffiti.UUCP (Peter da Silva)
  3201. Subject: Re: C bites Dog!
  3202. Message-ID: <131@graffiti.UUCP>
  3203. Date: 30 Aug 85 18:09:30 GMT
  3204. Date-Received: 2 Sep 85 05:44:17 GMT
  3205. References: <872@brl-tgr.ARPA> <1835@reed.UUCP>
  3206. Organization: Information Brokerage Network, Houston, TX
  3207. Lines: 11
  3208.  
  3209. --MORE--(53%)> > > > >               if (sv > score);   <----- note extraneous semi-colon
  3210. > > > > >                       score = sv;
  3211. > > > ICK ICK ICK! I hate languages that do that. Ever considered using "cb" as a
  3212. > > > debugging tool? I have an MS-DOS version if anyone wants it...
  3213. > > [...]  What
  3214. > > would you do, compare the output of `cb' with the original? Takes
  3215. > > lots of time & can be visually overlooked.
  3216.  
  3217. Yes. Since I write cb-like code in the first place it's very easy to just
  3218. diff it... any lines diff catches are either long function calls or errors
  3219. of this type.
  3220. (Mail) End of article 4930 (of 4956)--what next? [npq] 
  3221.  
  3222. Article 4931 (25 more) in net.lang.c:
  3223. From: guy@sun.uucp (Guy Harris)
  3224. Newsgroups: net.lang.c,net.unix-wizards
  3225. Subject: Re: Re: how has C bitten you?
  3226. Message-ID: <2737@sun.uucp>
  3227. Date: 31 Aug 85 04:36:43 GMT
  3228. Date-Received: 2 Sep 85 05:47:08 GMT
  3229. References: <302@brl-tgr.ARPA> <471@baylor.UUCP>, <148@chinet.UUCP> <607@bu-cs.UUCP>
  3230. Organization: Sun Microsystems, Inc.
  3231. Lines: 46
  3232.  
  3233. --MORE--(32%)> Not really a bite, but I remember when I was first learning C
  3234. > I was quite bewildered by the fact that you couldn't really
  3235. > declare your own 'argv', that is, you couldn't declare an
  3236. > array of pointers to fixed length buffers except perhaps by:
  3237. > char *myargv[] = {
  3238. >       "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
  3239. >       "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
  3240. >       etc
  3241. > I mean, argv seemed kinda holy to me, disturbing.
  3242.  
  3243. If you want an array of pointers to fixed-length buffers, you can declare it
  3244. as long as the number of such pointers can be determined at the time you
  3245. write the code.
  3246.  
  3247.         char bufs[3][20];
  3248.  
  3249.         char *bufps[3] = {
  3250.                 bufs[0],
  3251.                 bufs[1],
  3252.                 bufs[2],
  3253.         };
  3254.  
  3255. If the number can't be fixed when you write the code, you can set up "bufps"
  3256. at run time.
  3257.  
  3258. Also note that "argv" isn't a pointer to an array of pointers to fixed-length
  3259. buffers, it's a pointer to an array of pointers to strings, which you *can*
  3260. declare.
  3261.  
  3262. > P.S. I know argv is var length, but that would be even harder to declare!
  3263.  
  3264. The secret is that "argv" (or, more correctly, what "argv" points to)
  3265. *isn't* declared.  Pointers need not point to things which have been
  3266. declared; "malloc" returns pointers to objects fabricated on the fly.  If
  3267. you have "n" arguments ("n" is a variable here), just do
  3268.  
  3269.         register char **argv;
  3270.  
  3271.         argv = (char **)malloc(n * sizeof(char *));
  3272.  
  3273. And you can fill them in.
  3274.  
  3275.         Guy Harris
  3276. (Mail) End of article 4931 (of 4956)--what next? [npq] 
  3277.  
  3278. Article 4932 (24 more) in net.lang.c:
  3279. From: doug@terak.UUCP (Doug Pardee)
  3280. Subject: Re: Order of evaluation
  3281. Message-ID: <692@terak.UUCP>
  3282. Date: 30 Aug 85 18:01:29 GMT
  3283. Date-Received: 2 Sep 85 06:13:44 GMT
  3284. References: <764@dataio.UUCP>
  3285. Organization: Calcomp Display Products Division, Scottsdale, AZ, USA
  3286. Lines: 17
  3287.  
  3288. --MORE--(41%)> >OK, I understand that order of evaluation is not guaranteed.  I assume that
  3289. > >was done to make compilers easier to write.  Is there any other reason?  Does> >it really make compilers easier to write?
  3290. > Also, allowing the compiler to reorder the expression within certain
  3291. > limits allows it to do some optimizations. Most code is not affected by
  3292. > order of evaluation, and C does allow an order to be forced (by assigning
  3293. > an explicit temporary), so I think this is very reasonable.
  3294.  
  3295. What drives me up a wall is that C does *not* allow an order to be
  3296. forced by using parentheses!  The compiler is at liberty to ignore
  3297. parens which group operators of the same precedence.  <e.g. a+(b+c)>
  3298.  
  3299. I don't think much of the notion of having to store intermediate results
  3300. just to get the correct answer.
  3301. -- 
  3302. Doug Pardee -- CalComp -- {seismo!noao,decvax!noao,ihnp4}!terak!doug
  3303. (Mail) End of article 4932 (of 4956)--what next? [npq] 
  3304.  
  3305. Article 4933 (23 more) in net.lang.c:
  3306. From: nazgul@apollo.uucp (Kee Hinckley)
  3307. Subject: Wanted: Info on C Interpreters
  3308. Message-ID: <289ebe40.8e4@apollo.uucp>
  3309. Date: 29 Aug 85 17:45:43 GMT
  3310. Date-Received: 2 Sep 85 06:22:21 GMT
  3311. Organization: Apollo Computer, Chelmsford, Mass.
  3312. Lines: 23
  3313.  
  3314. --MORE--(37%)<now you c me now you don't>
  3315.  
  3316. I'm looking for any information anyone can give me on C interpreters,
  3317. primarily ones that run on Unix, but info on others is welcome.  In
  3318. particular I'd like to know:
  3319.  
  3320.     Who makes it?
  3321.     What is it written in?
  3322.     How does it work (pcode, trees...)?
  3323.     How good is it?
  3324.     And of course...  How much does it cost?
  3325.     And anything else you'd like to add.
  3326.  
  3327.  
  3328.                                             Kee Hinckley
  3329.                                             (617) 256-6600
  3330.                                             ...decvax!wanginst!apollo!nazgul
  3331.  
  3332.                                 
  3333. The views expressed herein are not necessarily those of Apollo Computer, since
  3334. views are naturally expressed in a block structured environment.  Apollo forms
  3335. the containing block in which I reside, but the views expressed herein are all
  3336. in local variables that temporarily override any views help by Apollo Computer.
  3337. (Mail) End of article 4933 (of 4956)--what next? [npq] 
  3338.  
  3339. Article 4934 (22 more) in net.lang.c:
  3340. From: cottrell@nbs-vms.ARPA (COTTRELL, JAMES)
  3341. Subject: This Sentence is False
  3342. Message-ID: <1118@brl-tgr.ARPA>
  3343. Date: 30 Aug 85 01:20:41 GMT
  3344. Date-Received: 2 Sep 85 06:25:09 GMT
  3345. Sender: news@brl-tgr.ARPA
  3346. Lines: 97
  3347.  
  3348. --MORE--(12%)/* Fiercely I go into battle:
  3349. > I have always thought that to be a machine dependancy (the value of true and
  3350. > false).  Maybe I'm wrong.  But, different machines DO have different ideas
  3351. > of which is true and false (at the assembler level).  And it is simply
  3352. > a convention.
  3353.  
  3354. Machines have no concept of truth. They can determine if a condition
  3355. (equality, greater than, negative, overflow, etc.) exists and then
  3356. *dynamically* alter the course of their control flow. But no machine
  3357. I know of has a `branch if true' instruxion. Note I am not talking
  3358. about the abstraxion a la 68k where an unconditional branch is named
  3359. `branch if true' & the converse is called `branch if false'. I am 
  3360. talking about a *conditional* `branch if true'.
  3361.  
  3362. > Still though, #define TRUE (1==1) is very obvious, to the point, correct,
  3363. > proper, and all sorts of things.  And it doesn't require one to know
  3364. > that detail about C that the convention is ~0 == TRUE and 0 == FALSE.
  3365.  
  3366. Your attention span must be even shorter than mine. (What were we talking
  3367. about :-) If you are consistant, ignorance is bliss. But what about
  3368. fred's code over there, if (p). Hmmmm, now what does that do?
  3369.  
  3370. > But C gives you all these operators which allow you to define things
  3371. > machine independantly rather than hardcoding values.  Obviously I mean
  3372. > casts and the sizeof operator.  Also arithmetic to pointers.  So why not
  3373. > TRUE and FALSE?
  3374. > --- David Herron
  3375.  
  3376. Because who needs them? Integers do quit well, thank you.
  3377. On to my next victim.
  3378.  
  3379. > Not really.  You could usually safely assume that if someone is defining
  3380. > true and false, he/she is defining it as above.  (if some joker decides
  3381. > to define false as 29 and true as 53, he should be forced for eternity
  3382. > to covert 10,000-line APL programs to Fortran! :-) )
  3383.  
  3384. Agreed. But it's not 29 & 53 were talking about now is it? Zero & One
  3385. have certain useful mathematical properties, described below.
  3386.  
  3387. > I think it is much easier to read things such as:
  3388. >
  3389. >    done = true;
  3390. > than:
  3391. >    done = 1;
  3392.  
  3393. How about `done++'. Most variables are initialized to false. It's
  3394. kinda like reality, nothing can be taken for granted (default false)
  3395. unless it appears to be true.
  3396.  
  3397. > Of course, explanatory comments in any case improves readability even
  3398. > more.
  3399. > Dan Howell
  3400.  
  3401. Most definitely. Now for the last one:
  3402.  
  3403. > To me, the mapping TRUE -> 0 and FALSE -> non-zero doesn't seem obvious,
  3404. > and I'm sure it isn't to most programmers who ever worked in assembler.
  3405. > In assembler, one often writes the following (I'm using pseudocode
  3406. > rather than any particular assembler):
  3407. >       compare two values
  3408. >       jumpto stuff  if zero
  3409. > Which is the assembler equivalent of
  3410. >         if (value1 == value2)
  3411. >         <do stuff> ;
  3412.  
  3413. I think you've got it backwards. 
  3414.  
  3415. > When I was in high school I was programming TRS-80's in both assembler
  3416. > and BASIC, and I had lots of trouble remembering whether BASIC
  3417. > represented truth as zero or -1.  No such memory is needed for the
  3418. > assembler, of course, since comparison is merely done by subtraction (a
  3419. > compare instruction is usually just a subtract instruction that doesn't
  3420. > store the result anywhere), so it is obvious what the zero indicator
  3421. > means.  It is not so obvious to me that in C 0 should mean false and 1
  3422. > mean true.
  3423. > -- 
  3424. >     Barry Margolin
  3425. >     ARPA: barmar@MIT-Multics
  3426. >     UUCP: ..!genrad!mit-eddie!barmar
  3427.  
  3428. Ah but it is! Consider the mathematical implications of it! The MAX
  3429. funxion is just the expression `(A > B) * A + (A < B) * B'. APL, which
  3430. was designed by a mathematician, uses the exact same concept. The
  3431. idea of `P implies Q' can be written as `P <= Q'! There have been many
  3432. different *conventions* used in many languages to represent the
  3433. *hidden* boolean values, sometimes differing between implementations.
  3434. I think time will show that APL & C do it the best way. At least the
  3435. cat's out of the bag & everybody knows what the spots look like.
  3436.  
  3437.         jim             cottrell@nbs
  3438. */
  3439. ------
  3440. (Mail) End of article 4934 (of 4956)--what next? [npq] 
  3441.  
  3442. Article 4935 (21 more) in net.lang.c:
  3443. From: cottrell@nbs-vms.ARPA (COTTRELL, JAMES)
  3444. Subject: I Do Declare!
  3445. Message-ID: <1113@brl-tgr.ARPA>
  3446. Date: 29 Aug 85 22:09:59 GMT
  3447. Date-Received: 2 Sep 85 06:51:46 GMT
  3448. Sender: news@brl-tgr.ARPA
  3449. Lines: 41
  3450.  
  3451. --MORE--(29%)/*
  3452. In article <368@persci.UUCP> roman@persci.UUCP writes:
  3453. > Either I'm missing the perfectly obvious or I've found something
  3454. > that's impossible to declare in C, even though it makes sense.  I'm
  3455. > trying to implement a simple finite state machine with states
  3456. > represented by C functions.  Each state function would accept some
  3457. > input value as an argument and return a pointer to the function
  3458. > implementing the next state...
  3459.  
  3460. Cheat! Declare your variable as a pointer to funxion returning int
  3461. (or char (or void) pointer for sticklers) and then use casts.
  3462. Saves a lot of headaches trying to figure out all those types.
  3463. With char or void pointers, there ought to be a portable way.
  3464.  
  3465. typedef int      (*PFI)();
  3466. typedef char    *(*PFCP)();     /* for portability sticklers */
  3467. typedef void    *(*PFVP)();     /* if available */
  3468.  
  3469. int     other();
  3470. int     init();                 /* initial func */
  3471. PFI     state = init;           /* state var */
  3472.  
  3473. init(arg)
  3474. {
  3475.         state = other;          /* no problem to set directly */
  3476.         ...
  3477.         return((int)state);     /* to return we must cast */
  3478.         ...
  3479.         state = (PFI)other(arg);/* must cast to assign */
  3480.         ...
  3481.         (*state)(arg);          /* can be called directly */
  3482.         ...
  3483.         while (state = (PFI)(*state)(arg));     /* until no more funx */
  3484. }
  3485.  
  3486. Once in a while you get shown the light
  3487. In the strangest of places if you look at it right.
  3488.  
  3489.         jim             cottrell@nbs
  3490. */
  3491. ------
  3492. (Mail) End of article 4935 (of 4956)--what next? [npq] 
  3493.  
  3494. Article 4936 (20 more) in net.lang.c:
  3495. From: gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>)
  3496. Subject: Re: C bites Dog! / project proposal
  3497. Message-ID: <1101@brl-tgr.ARPA>
  3498. Date: 29 Aug 85 18:48:51 GMT
  3499. Date-Received: 2 Sep 85 06:56:25 GMT
  3500. References: <872@brl-tgr.ARPA> <2968@sdcc3.UUCP> <159@chinet.UUCP>
  3501. Organization: Ballistic Research Lab
  3502. Lines: 9
  3503.  
  3504. --MORE--(60%)Judging by rlk's language proposal, he doesn't like those things
  3505. that C lovers think are C's greatest advantages.  He is certainly
  3506. entitled to his opinion (and his own language), so I hope we can
  3507. avoid zillions of return flames on this.
  3508.  
  3509. > ... but I personnaly prefer the clarity of PL/I to the terseness of C.
  3510.  
  3511. Besides, what can one say to a person who thinks PL/I is
  3512. distinguished by its clarity?
  3513. (Mail) End of article 4936 (of 4956)--what next? [npq] 
  3514.  
  3515.  
  3516. Article 4938 (18 more) in net.lang.c:
  3517. From: cottrell@nbs-vms.ARPA (COTTRELL, JAMES)
  3518. Subject: Array Declarations
  3519. Message-ID: <1106@brl-tgr.ARPA>
  3520. Date: 29 Aug 85 19:07:54 GMT
  3521. Date-Received: 2 Sep 85 06:57:00 GMT
  3522. Sender: news@brl-tgr.ARPA
  3523. Lines: 1
  3524.  
  3525. --MORE--(98%)------
  3526. (Mail) End of article 4938 (of 4956)--what next? [npq] 
  3527.  
  3528. Article 4939 (17 more) in net.lang.c:
  3529. From: cottrell@nbs-vms.ARPA (COTTRELL, JAMES)
  3530. Subject: Array Declarations
  3531. Message-ID: <1110@brl-tgr.ARPA>
  3532. Date: 29 Aug 85 20:04:51 GMT
  3533. Date-Received: 2 Sep 85 06:59:11 GMT
  3534. Sender: news@brl-tgr.ARPA
  3535. Lines: 42
  3536.  
  3537. --MORE--(25%)/*
  3538. > Not really a bite, but I remember when I was first learning C
  3539. > I was quite bewildered by the fact that you couldn't really
  3540. > declare your own 'argv', that is, you couldn't declare an
  3541. > array of pointers to fixed length buffers except perhaps by:
  3542. > char *myargv[] = {
  3543. >       "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
  3544. >       "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
  3545. > I mean, argv seemed kinda holy to me, disturbing.
  3546. >       -Barry Shein, Boston University
  3547. > P.S. I know argv is var length, but that would be even harder to declare!
  3548.  
  3549. Yeah. C will only create hidden literals of type char array. Wouldn't it
  3550. be nice to use expressions like `intptr = &2;' instead of the more
  3551. readable & nonportable `intptr = "\2\0\0\0";' (VAX) :-) Seriously tho,
  3552. remember DEC Fortran's `vectored arrays'? Why not get rid of `real'
  3553. arrays as well, & make them all pointers. When we declare: 
  3554.  
  3555.                 int     array[3][5];
  3556.  
  3557. let's really let the compiler do:
  3558.  
  3559.                 int     ??[15];
  3560.                 int     *?[3] = { ?? + 0, ?? + 5, ?? + 10};
  3561.                 int     **array = ?;
  3562.  
  3563. where `?' & `??' are invisible `names' known only to the compiler.
  3564. Forgive me if I got the subscripts backwards. This would lose for one
  3565. dimensional arrays & constant references to multidimensional arrays, but
  3566. gain speed on random refs to multiple arrays. The extra space is the
  3567. price one pays for consistancy. Or maybe only higher dimension arrays
  3568. should be vectored. To gain vectoring one would tack on `[1]' to an
  3569. array name or use the (nonexistent) keyword `vectored'. Or maybe nobody
  3570. cares. Just idle thoughts.
  3571.  
  3572.         jim             cottrell@nbs
  3573. */
  3574. ------
  3575. (Mail) End of article 4939 (of 4956)--what next? [npq] 
  3576.  
  3577. Article 4940 (16 more) in net.lang.c:
  3578. From: cottrell@nbs-vms.ARPA (COTTRELL, JAMES)
  3579. Subject: No Such Thing
  3580. Message-ID: <1112@brl-tgr.ARPA>
  3581. Date: 29 Aug 85 20:48:56 GMT
  3582. Date-Received: 2 Sep 85 06:59:23 GMT
  3583. Sender: news@brl-tgr.ARPA
  3584. Lines: 124
  3585.  
  3586. --MORE--(9%)/*
  3587. > From: Mike (I'll be mellow when I'm dead) Meyer <mwm@ucbopal.CC>
  3588.  
  3589. That's MY slogan too.
  3590.  
  3591. > In 868@brl-tgr.ARPA jim cottrell (cottrell@nbs-vms.ARPA) says:
  3592. > > Flame On! THERE IS NO SUCH THING AS A BOOLEAN!!! Flame Off.
  3593. > :-) Ok, we now know that jim doesn't believe in true and false. Does
  3594. > he drop right and wrong at the same time? How about write and read? :-)
  3595.  
  3596. Cute.
  3597.  
  3598. > > In case you hadn't noticed, `<' & company are infix operator that
  3599. > > return a constant `zero' or `one'. Thus, *every* conditional using
  3600. > > the `boolean' operators ultimately reduces to either
  3601. > >     if (0) { ... }          or      if (1) { ... }
  3602. > > THIS IS NOT A KLUDGE! It is the WAY IT SHOULD BE! What could be
  3603. > > more mnemonic (except to a nihilist :-) than TRUE if nonzero, and
  3604. > > FALSE if zero. One of C's design virtues is that it is minimal, yet
  3605. > > (relatively) complete. Don't drag outmoded concepts into the future!
  3606. > TRUE if nonzero, FALSE if zero? Sounds like jim just built a map from
  3607. > the set of C integers to booleans. But booleans don't exist, so such a
  3608. > map can't exist. Maybe what jim meant was:
  3609. >       if (expression) { ... }
  3610. > is the same as:
  3611. >       if expression is non-zero then { ... }.
  3612.  
  3613. That's what the book says.
  3614.  
  3615. > BTW, for something more mnemonic that
  3616. >       0 -> FALSE, {x | x /= 0} -> TRUE,
  3617. > how about
  3618. >       nil -> FALSE, {x | x /= nil} -> TRUE, or
  3619. >       {x | x = 0 mod 2} -> TRUE, {x | x = 1 mod 2} -> FALSE?
  3620.  
  3621. As for the first, sounds like LISP. Are you proposing a funny predefined
  3622. `thing' called `nil' that points to itself like in LISP? Will we have
  3623. to cast all our tests to the proper type?
  3624.  
  3625. As for the first, sounds like VAX Fortran. Since the VAX is 
  3626. little-endian, the low bit test words on all LOGICAL*[124] types. 
  3627.  
  3628. There have been all sorts of true-false mappings & conventions. Let's
  3629. not forget using the sign bit. Anyway, to my mind, (& evidently to
  3630. K&R) the use of zero to represent false is the most reasonable
  3631. thing to do, if restricted to *in-band* values. When you ain't
  3632. got nothin', you got nothin' to lose.
  3633.  
  3634. > Second BTW: C is not minimal. It's not bad, but there a half-dozen or
  3635. > so languages that have fewer operators, and equivalent completeness.
  3636. > Most of those are harder to use than C, though.
  3637.  
  3638. Okay. What I mean by minimal is that it includes only those features
  3639. truly necessary to fully describe an idealized portable machine and 
  3640. which have meaning to the compiler. There is no exponentiation because
  3641. few (if any) machines have it as a primitive. There is no repeat-until
  3642. statement because that is a trivial variation of a while. There is no
  3643. I/O, sets, booleans, complex numbers, or inline functions (except 
  3644. sizeof) that most other general purpose languages have.
  3645.  
  3646. > > > Many Boolean expressions are not best thought of as comparison of
  3647. > > > an arithmetic quantity against zero.  For example:
  3648. > > >   while ( ! Done() )
  3649. > > >           Perform_Action();
  3650. > > 
  3651. > > We agree, but for different reasons. You insist on dragging in
  3652. > > an outmoded concept, then complaining that it doesn't fit very well.
  3653. > > I just read what it says.
  3654. > Sorry, but you've got it backwards. He's trying to pull a modern
  3655. > concept (TRUTH :-) into an obsolete language. Of course, if your
  3656. > language is nothing more than a high-level assembler, then using the
  3657. > funny "zero is false" map is ok, providing the underlying hardware
  3658. > doesn't provide a boolean type of it's own.
  3659.  
  3660. Like What? Zero is the most unique & important constant in the universe!
  3661. All (or 99.99%) machines have a branch on (non)zero & some even have
  3662. clear instruxions. 
  3663.  
  3664. > > > I am pretty conservative
  3665. > > 
  3666. > > I think this pretty much sums it up.
  3667. > Yeah - somebody who expects the programming languages to make their
  3668. > job easier is pretty conservative. I'm that way to - I want a language
  3669. > that makes it easy to turn my thoughts into code. This is why I prefer
  3670. > ALGOLW or C to FORTRAN or BASIC, and CLU or LISP to ALGOLW or C.
  3671.  
  3672. Why do you keep putting a `W' on the end of `ALGOL'? I haven't a CLU :-)
  3673.  
  3674. > > Actually, Doug, I'm not so much writing this to you as much as
  3675. > > all those other people out there who insist on fortrash as a model
  3676. > > for all their computing. Sorry about the cheap shot, but I wish you
  3677. > > were a little more daring in your philosophy. K & R were.
  3678. > Sorry, but I can't resist: Jim, from where I stand, *you* insist on
  3679. > fortrash as a model for your computing. There are more similarities
  3680. > between C and fortrash than differences. The C "if x is zero then ..."
  3681. > reminds me of the fortrash arithmetic if. But further discussion
  3682. > belongs in net.lang.*
  3683.  
  3684. Twisting things around a bit aren't we? I never even used the
  3685. arithmatic if except when I was a freshman & thought it was cute.
  3686. There are two main features of a language as I see it: 1) control
  3687. struxures, & 2) data struxures. Fortran 77 has matured somewhat in
  3688. the former, but leaves a lot to be desired in the latter.
  3689.  
  3690. >       <mike
  3691. > "Truth is variable."
  3692. > * disclaimer: I like C. It's easily the best language to come out of
  3693. > the early '70s I've seen. However, this does not imply that 1) it's
  3694. > perfect; or 2) there aren't better general purpose languages
  3695. > available.
  3696.  
  3697. 1) Agreed. I have criticized C as well in this very forum.
  3698. 2) Maybe so. But *widely* available?
  3699.  
  3700.         jim             cottrell@nbs
  3701. */
  3702. ------
  3703. (Mail) End of article 4940 (of 4956)--what next? [npq] 
  3704.  
  3705. Article 4941 (15 more) in net.lang.c:
  3706. From: cottrell@nbs-vms.ARPA (COTTRELL, JAMES)
  3707. Subject: No Such Thing
  3708. Message-ID: <1116@brl-tgr.ARPA>
  3709. Date: 29 Aug 85 23:56:53 GMT
  3710. Date-Received: 2 Sep 85 07:03:41 GMT
  3711. Sender: news@brl-tgr.ARPA
  3712. Lines: 11
  3713.  
  3714. --MORE--(64%)/*
  3715. > I don't understand the point of explaining how C maps
  3716. > natural booleans into arithmetic terms; that is just
  3717. > what I am complaining about.
  3718.  
  3719. Does anyone else besides Gwyn have trouble with mapping booleans to integers?
  3720. (Sorry Doug, I just couldn't resist :-)
  3721.  
  3722.         jim             cottrell@nbs
  3723. */
  3724. ------
  3725. (Mail) End of article 4941 (of 4956)--what next? [npq] 
  3726.  
  3727. Article 4942 (14 more) in net.lang.c:
  3728. From: Purtill@MIT-MULTICS.ARPA (Mark Purtill)
  3729. Subject: Re(n): null loop bodies
  3730. Message-ID: <1117@brl-tgr.ARPA>
  3731. Date: 30 Aug 85 00:12:41 GMT
  3732. Date-Received: 2 Sep 85 07:03:58 GMT
  3733. Sender: news@brl-tgr.ARPA
  3734. Lines: 17
  3735.  
  3736. --MORE--(61%)<Fnord>
  3737. I use either:
  3738.  
  3739.           while (test ) ; /* no body! */
  3740.  
  3741. or
  3742.           
  3743.           while (test ) {
  3744.                     ;
  3745.                     }
  3746.  
  3747. depending on space (on the screen) considerations.  Or at least I ought
  3748. to.
  3749.  
  3750.        Mark
  3751. ^.-.^  Purtill at MIT-MULTICS.ARPA    **Insert favorite disclaimer here**
  3752. (("))  2-032 MIT Cambrige MA 02139
  3753. (Mail) End of article 4942 (of 4956)--what next? [npq] 
  3754.  
  3755. Article 4943 (13 more) in net.lang.c:
  3756. From: bc@cyb-eng.UUCP (Bill Crews)
  3757. Subject: Re: "handy.h"
  3758. Message-ID: <685@cyb-eng.UUCP>
  3759. Date: 30 Aug 85 15:02:54 GMT
  3760. Date-Received: 2 Sep 85 07:19:58 GMT
  3761. References: <10200006@ada-uts.UUCP>
  3762. Organization: Cyb Systems, Austin, TX
  3763. Lines: 17
  3764.  
  3765. --MORE--(50%)> 
  3766. > I'm interested in coming up with an include file, say "handy.h",
  3767. >
  3768. > -- Rich Wagner
  3769.  
  3770. If people, when choosing names for functions, variables, files, etc, would
  3771. think at least briefly about what name would be the most meaningful to an
  3772. uninitiated reader, we readers would have a much easier time.  I would
  3773. suggest you come up with names like types.h or ctlchars.h or whatever,
  3774. segregate them functionally and name them appropriately.
  3775.  
  3776. -- 
  3777.   /  \    Bill Crews
  3778.  ( bc )   Cyb Systems, Inc
  3779.   \__/    Austin, Texas
  3780.  
  3781. [ gatech | ihnp4 | nbires | seismo | ucbvax ] ! ut-sally ! cyb-eng ! bc
  3782. (Mail) End of article 4943 (of 4956)--what next? [npq] 
  3783.  
  3784. Article 4944 (12 more) in net.lang.c:
  3785. From: jeff@isi-vaxa (Jeffery A. Cavallaro)
  3786. Subject: Re: \"handy.h\"
  3787. Message-ID: <1133@brl-tgr.ARPA>
  3788. Date: 30 Aug 85 16:48:17 GMT
  3789. Date-Received: 2 Sep 85 07:20:52 GMT
  3790. Sender: news@brl-tgr.ARPA
  3791. Lines: 12
  3792.  
  3793. --MORE--(53%)Well, for starters you should take a look at the specification for the
  3794. portability definition file "stdtype.h" described in the PLUM HALL
  3795. document "C PROGRAMMING STANDARDS AND GUIDELINES".  The latest version I
  3796. have is JAN-1982, edition 3.  In this addition, stdtype is described in
  3797. section 1.3.  Every site should have a version for each particular
  3798. machine type.
  3799.  
  3800. In addition, I would suggest the following:
  3801.  
  3802. #define         FALSE           0
  3803. #define         TRUE            1
  3804. #define         EOL             '\0'            /* End-of-line */
  3805. (Mail) End of article 4944 (of 4956)--what next? [npq] 
  3806.  
  3807. Article 4945 (11 more) in net.lang.c:
  3808. From: jeff@isi-vaxa.ARPA (Jeffery A. Cavallaro)
  3809. Subject: Re: \"handy.h\"
  3810. Message-ID: <1135@brl-tgr.ARPA>
  3811. Date: 30 Aug 85 17:29:54 GMT
  3812. Date-Received: 2 Sep 85 07:21:07 GMT
  3813. Sender: news@brl-tgr.ARPA
  3814. Lines: 12
  3815.  
  3816. --MORE--(53%)Well, for starters you should take a look at the specification for the
  3817. portability definition file "stdtype.h" described in the PLUM HALL
  3818. document "C PROGRAMMING STANDARDS AND GUIDELINES".  The latest version I
  3819. have is JAN-1982, edition 3.  In this addition, stdtype is described in
  3820. section 1.3.  Every site should have a version for each particular
  3821. machine type.
  3822.  
  3823. In addition, I would suggest the following:
  3824.  
  3825. #define         FALSE           0
  3826. #define         TRUE            1
  3827. #define         EOL             '\0'            /* End-of-line */
  3828. (Mail) End of article 4945 (of 4956)--what next? [npq] 
  3829.  
  3830. Article 4946 (10 more) in net.lang.c:
  3831. From: weltyrp@rpics.UUCP (Richard Welty)
  3832. Subject: Re: Re: Re: C bites (Null loop-bodies)
  3833. Message-ID: <176@rpics.UUCP>
  3834. Date: 31 Aug 85 00:18:52 GMT
  3835. Date-Received: 2 Sep 85 08:18:51 GMT
  3836. References: <165@3comvax.UUCP> <418@phri.UUCP> <958@bunker.UUCP>
  3837. Distribution: net
  3838. Organization: RPI CS Department, Troy  NY
  3839. Lines: 37
  3840.  
  3841. --MORE--(42%)> >     I put null loop-bodies on a separate line like in the following
  3842. > > example.
  3843. > > 
  3844. > >             while (eatup() != '\n')
  3845. > >                     ;
  3846. > Putting the semi-colon on a separate line does help make it clear
  3847. > that the body of the loop is intentionally null, but what I like
  3848. > even better is:
  3849. >               while( eatup() != '\n' )
  3850. >                       continue;
  3851. I personally like to use {} in all cases ... thus:
  3852.  
  3853.         while( eatup() != '\n'){}
  3854. or
  3855.         while( eatup() != '\n')
  3856.             {}
  3857. or even
  3858.         while( eatup() != '\n')
  3859.         {
  3860.         }
  3861. By using the {} all the time, even for null cases, I insure
  3862. that things like
  3863.         if( cond);
  3864. don't happen ...
  3865. -- 
  3866.                                 Rich Welty
  3867.  
  3868.         (I am both a part-time grad student at RPI and a full-time
  3869.          employee of a local CAE firm, and opinions expressed herein
  3870.          have nothing to do with anything at all)
  3871.  
  3872.         CSNet:   weltyrp@rpi
  3873.         ArpaNet: weltyrp.rpi@csnet-relay
  3874.         UUCP:  seismo!rpics!weltyrp
  3875. (Mail) End of article 4946 (of 4956)--what next? [npq] 
  3876.  
  3877. Article 4947 (9 more) in net.lang.c:
  3878. From: eppstein@columbia.UUCP (David Eppstein)
  3879. Subject: Re: Re: c programming style - READ THIS
  3880. Message-ID: <1020@columbia.UUCP>
  3881. Date: 31 Aug 85 18:38:03 GMT
  3882. Date-Received: 2 Sep 85 08:19:10 GMT
  3883. References: <90@rtp47.UUCP> <5400011@prism.UUCP>
  3884. Reply-To: eppstein@columbia.UUCP (David Eppstein)
  3885. Organization: Columbia University
  3886. Lines: 25
  3887.  
  3888. --MORE--(31%)In article <5400011@prism.UUCP> mer@prism.UUCP writes:
  3889. > Since 'p+n', where p is a pointer and n is an integer, is equivalent to
  3890. > adding n*sizeof(whatever p points to), the safe and portable way of adding
  3891. > an integer to a pointer treated as an integer is 
  3892. >        (char *)p + n
  3893. > since (I think) character are always a byte wide.  If that's not always the
  3894. > case, I apologize; on the other hand, it's probably safe than converting
  3895. > a pointer to an int or a long;  I had trouble porting something from a VAX
  3896. > to a Pyramid because of a cast of this sort.
  3897.  
  3898. Not the case.  For instance on the DEC-20, adding integers to (int *)
  3899. looks like adding integers to integers but adding them to (char *)
  3900. does something totally different (divides by number of bytes per word,
  3901. adds word quotient as an integer, adds number of bytes remainder
  3902. multiplied by byte size shifted over by 30 bits; bytes per word and
  3903. bits per byte have to be calculated from the pointer itself because
  3904. we have both 7-bit bytes packed 5 to a word and 9-bit bytes packed
  3905. 4 to a word (others too but those are the ones used in C); this is not
  3906. as bad as it sounds because there is a machine instruction to do it all).
  3907.  
  3908. On all implementations that I know about, coercing the pointer to (long) and
  3909. adding your integer will work.  However this is still somewhat nonportable
  3910. and you are better off doing whatever you are trying to do some other,
  3911. clean, portable way not involving adding integers as integers to pointers.
  3912. (Mail) End of article 4947 (of 4956)--what next? [npq] 
  3913.  
  3914. Article 4948 (8 more) in net.lang.c:
  3915. From: rcd@opus.UUCP (Dick Dunn)
  3916. Subject: Re: Cryptic C (enum as boolean type)
  3917. Message-ID: <19@opus.UUCP>
  3918. Date: 30 Aug 85 05:02:04 GMT
  3919. Date-Received: 2 Sep 85 08:30:59 GMT
  3920. References: <2913@ncsu.UUCP> <709@brl-tgr.ARPA> <1056@mtgzz.UUCP>
  3921. Organization: NBI,Inc, Boulder CO
  3922. Lines: 16
  3923.  
  3924. --MORE--(45%)> Instead of using #defines for the boolean values, I
  3925. > would rather see enumerated data types used.  In general,
  3926. > C programmers seem to prefer #defines to defining a data
  3927. > type that can be checked during compilation.
  3928. >       typedef enum { False , True } Boolean;
  3929.  
  3930. Whether this works depends on your compiler's view of enums.  If it treats
  3931. enums as a slight variant on integers (which to my tastes is pretty
  3932. sloppy), you're OK.  However, if it uses the very restricted view which
  3933. doesn't allow arithmetic on enums, the above definition will prevent the
  3934. "usual" logical operators !, &, ^, and | from working with objects of type
  3935. Boolean.
  3936. -- 
  3937. Dick Dunn       {hao,ucbvax,allegra}!nbires!rcd         (303)444-5710 x3086
  3938.    ...Relax...don't worry...have a homebrew.
  3939. (Mail) End of article 4948 (of 4956)--what next? [npq] 
  3940.  
  3941. Article 4949 (7 more) in net.lang.c:
  3942. From: lee@eel.UUCP
  3943. Subject: Re: Re: how has C bitten you?  (Really,
  3944. Message-ID: <2000001@eel.UUCP>
  3945. Date: 29 Aug 85 02:52:00 GMT
  3946. Date-Received: 3 Sep 85 04:00:53 GMT
  3947. References: <259@watmum.UUCP>
  3948. Lines: 24
  3949.  
  3950. --MORE--(31%)
  3951. >>Gee....and I thought a zero pointer was guaranteed not to point to
  3952. >>anything valid (K&R says this).
  3953.  
  3954. >All valid implementations of C guarantee this.  Obviously, the
  3955. >implementation of C that this was done on is not valid.  He should complain
  3956. >to the vendor.  (Yes, there have been such implementations; one well-known
  3957. >chip maker's first UNIX release didn't put the necessary shim at data
  3958. >location 0 on a separate I&D space program.  They fixed it shortly
  3959. >afterwards.)
  3960.  
  3961. Speaking of issues that have been beaten to death!  K&R says only that the
  3962. value 0 is distinguishable from pointers that point to objects, and that
  3963. therefore the value zero is not a "valid" pointer.  It certainly does not
  3964. say that the 0 pointer will give you the "null" or empty value of any
  3965. object, and in particular it does not promise that there will be an integer
  3966. zero if you dereference (int*)0, or a character zero if you dereference
  3967. (char*)0, nor a memory fault if you reference (foo*)0.
  3968.  
  3969. NO, you cannot depend upon the value obtained by dereferencing ANY pointer
  3970. that has been assigned the value zero.  It does not point to any object;
  3971. the implementation of C does not guarantee  to protect you from erroneously
  3972. trying to access that object and the result is unpredictable over various
  3973. implementations.
  3974. (Mail) End of article 4949 (of 4956)--what next? [npq] 
  3975.  
  3976. Article 4950 (6 more) in net.lang.c:
  3977. From: darryl@ISM780.UUCP
  3978. Subject: Re: Re: how has C bitten you?  (Really,
  3979. Message-ID: <30000009@ISM780.UUCP>
  3980. Date: 29 Aug 85 13:48:00 GMT
  3981. Date-Received: 3 Sep 85 04:01:11 GMT
  3982. References: <259@watmum.UUCP>
  3983. Lines: 19
  3984.  
  3985. --MORE--(40%)
  3986. []
  3987.  
  3988. One final, subtle, point.  K&R does not guarantee that the *value* 0 is
  3989. distinguishable from all other pointers, but rather, that the *constant* 0
  3990. is.  That is to say, you may compare against 0 to determine the validity of
  3991. a pointer (or assign to guarantee invalidity), but you may not assume that
  3992. comparison against (or assignment of) an int variable whose value is 0 will
  3993. have the same result.  This picky distinction probably doesn't affect any
  3994. of the better known chips, but might be important on a machine where a null
  3995. pointer is not a bit string of 0s.
  3996.  
  3997.             --Darryl Richman, INTERACTIVE Systems Corp.
  3998.             ...!cca!ima!ism780!darryl
  3999.             The views expressed above are my opinions only.
  4000.  
  4001. P.S.:  I know that this sounds amazing, so look at the top of K&R p190,
  4002. under the section 7.7, equality operators (second paragraph), and again
  4003. on top of p192, section 7.14, assignment operators.
  4004. (Mail) End of article 4950 (of 4956)--what next? [npq] 
  4005.  
  4006. Article 4951 (5 more) in net.lang.c:
  4007. From: richw@ada-uts.UUCP
  4008. Subject: "handy.h"
  4009. Message-ID: <10200006@ada-uts.UUCP>
  4010. Date: 28 Aug 85 14:39:00 GMT
  4011. Date-Received: 3 Sep 85 04:01:19 GMT
  4012. Lines: 16
  4013.  
  4014. --MORE--(52%)
  4015. I'm interested in coming up with an include file, say "handy.h",
  4016. which declares a lot of commonly useful "stuff".  A lot of discussion
  4017. (an AWFUL lot) has been going on about Boolean typedefs/defines --
  4018. that's the sort of thing I'm looking for:
  4019.  
  4020.     typedef enum { false, true } bool;
  4021.  
  4022. Other plausible candidates for this "second stdio.h" might be:
  4023.  
  4024.     typedef char *string;
  4025.     #define FORMFEED '\014'      /*  ASCII form feed  */
  4026.  
  4027. Any other suggestions would be appreciated.
  4028.  
  4029. -- Rich Wagner
  4030. (Mail) End of article 4951 (of 4956)--what next? [npq] 
  4031.  
  4032.  
  4033. Article 4954 (2 more) in net.lang.c:
  4034. From: peter@graffiti.UUCP (Peter da Silva)
  4035. Subject: Re: \"handy.h\"
  4036. Message-ID: <148@graffiti.UUCP>
  4037. Date: 31 Aug 85 14:40:13 GMT
  4038. Date-Received: 3 Sep 85 05:21:58 GMT
  4039. References: <1133@brl-tgr.ARPA>
  4040. Organization: The Power Elite, Houston, TX
  4041. Lines: 8
  4042.  
  4043. --MORE--(78%)> #define               FALSE           0
  4044. > #define               TRUE            1
  4045. > #define               EOL             '\0'            /* End-of-line */
  4046.  
  4047. #define EOL '\n'
  4048. #define EOS '\0'
  4049.  
  4050. ... unless, of course, you're on a really weird O/S.
  4051. (Mail) End of article 4954 (of 4956)--what next? [npq] 
  4052.  
  4053. Article 4955 (1 more) in net.lang.c:
  4054. From: doug@terak.UUCP (Doug Pardee)
  4055. Subject: Numeric comparisons
  4056. Message-ID: <693@terak.UUCP>
  4057. Date: 30 Aug 85 18:29:16 GMT
  4058. Date-Received: 3 Sep 85 06:13:03 GMT
  4059. References: <10176@ucbvax.ARPA> <5118@mit-eddie.UUCP>
  4060. Organization: Calcomp Display Products Division, Scottsdale, AZ, USA
  4061. Lines: 24
  4062.  
  4063. --MORE--(41%)> ... since comparison is merely done by subtraction (a
  4064. > compare instruction is usually just a subtract instruction that doesn't
  4065. > store the result anywhere)...
  4066.  
  4067. Compiler writers note -- a comparison is not "just a subtract".
  4068. For example:
  4069.  
  4070. #define NBITS 16
  4071. /* NBITS is number of bits in an integer */
  4072.    int a, b;
  4073.    a = 3 << (NBITS-3);  /* 24576 for NBITS=16 */
  4074.    b = -a;
  4075.    if (a>b)
  4076.       printf("Comparison was done by bit-wise comparison\n");
  4077.    else
  4078.       printf("Comparison was done by subtraction\n");   /* WRONG */
  4079.  
  4080. Compiler users note -- if your compiler gives the wrong results, the
  4081. compiler writer might not be completely at fault.  Many early CPU
  4082. chips (8080A, Z80, 6502, etc.) did comparison by subtraction, and a
  4083. compiler would have had to generate extra code to test for Overflow
  4084. in order to get the correct result.
  4085. -- 
  4086. Doug Pardee -- CalComp -- {seismo!noao,decvax!noao,ihnp4}!terak!doug
  4087. (Mail) End of article 4955 (of 4956)--what next? [npq] 
  4088.  
  4089. Article 4956 in net.lang.c:
  4090. From: ark@alice.UucP (Andrew Koenig)
  4091. Subject: Re: Re: how has C bitten you?  (Really,
  4092. Message-ID: <4244@alice.UUCP>
  4093. Date: 30 Aug 85 16:04:11 GMT
  4094. Date-Received: 4 Sep 85 05:53:32 GMT
  4095. References: <2000001@eel.UUCP>
  4096. Organization: Bell Labs, Murray Hill
  4097. Lines: 27
  4098.  
  4099. --MORE--(25%)>>All valid implementations of C guarantee this.  Obviously, the
  4100. >>implementation of C that this was done on is not valid.  He should complain
  4101. >>to the vendor.  (Yes, there have been such implementations; one well-known
  4102. >>chip maker's first UNIX release didn't put the necessary shim at data
  4103. >>location 0 on a separate I&D space program.  They fixed it shortly
  4104. >>afterwards.)
  4105.  
  4106. >Speaking of issues that have been beaten to death!  K&R says only that the
  4107. >value 0 is distinguishable from pointers that point to objects, and that
  4108. >therefore the value zero is not a "valid" pointer.  It certainly does not
  4109. >say that the 0 pointer will give you the "null" or empty value of any
  4110. >object, and in particular it does not promise that there will be an integer
  4111. >zero if you dereference (int*)0, or a character zero if you dereference
  4112. >(char*)0, nor a memory fault if you reference (foo*)0.
  4113.  
  4114. >NO, you cannot depend upon the value obtained by dereferencing ANY pointer
  4115. >that has been assigned the value zero.  It does not point to any object;
  4116. >the implementation of C does not guarantee  to protect you from erroneously
  4117. >trying to access that object and the result is unpredictable over various
  4118. >implementations.
  4119.  
  4120. I think the "necessary shim" referred to in the first note quoted
  4121. above has nothing to do with a value intended to ensure that *(int*)0
  4122. give a defined value.  Rather, it is a dummy variable located at
  4123. location 0 designed to ensure the NOTHING ELSE find itself at location
  4124. 0 by accident!  The trouble with putting a variable at location 0
  4125. is that its address will then erroneously appear to be NULL.
  4126. (Mail) End of article 4956 (of 4956)--what next? [npq] 
  4127.  
  4128. End of newsgroup net.lang.c.
  4129.  
  4130.